简体中文
Telegram

帖子import java.util.*;

2025年2月9日
D
Deloitte | COGNIZANT | IBM | CAPGEMINI
import java.util.*; class Vehicle { protected String make; protected String model; protected int year; public Vehicle(String make, String model, int year) { this.make = make; this.model = model; this.year = year; } public void display() { System.out.print(make + ", " + model + ", " + year); } } class Car extends Vehicle { private int numDoors; public Car(String make, String model, int year, int numDoors) { super(make, model, year); this.numDoors = numDoors; } @Override public void display() { super.display(); System.out.println(", " + numDoors + " doors"); } public void update(int numDoors) { this.numDoors = numDoors; System.out.println("Car updated successfully."); } } class Bike extends Vehicle { private boolean hasCarrier; public Bike(String make, String model, int year, boolean hasCarrier) { super(make, model, year); this.hasCarrier = hasCarrier; } @Override public void display() { super.display(); System.out.println(", " + (hasCarrier ? "Has Carrier" : "No Carrier")); } public void update(boolean hasCarrier) { this.hasCarrier = hasCarrier; System.out.println("Bike updated successfully."); } } public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Map<String, Car> carInventory = new HashMap<>(); Map<String, Bike> bikeInventory = new HashMap<>(); while (true) { String command = scanner.nextLine().toLowerCase(); switch (command) { case "add car": System.out.print("Enter make: "); String carMake = scanner.nextLine(); System.out.print("Enter model: "); String carModel = scanner.nextLine(); System.out.print("Enter year: "); int carYear = scanner.nextInt(); System.out.print("Enter number of doors: "); int numDoors = scanner.nextInt(); scanner.nextLine(); // Consume newline carInventory.put(carModel, new Car(carMake, carModel, carYear, numDoors)); System.out.println("Car added successfully."); break; case "add bike": System.out.print("Enter make: "); String bikeMake = scanner.nextLine(); System.out.print("Enter model: "); String bikeModel = scanner.nextLine(); System.out.print("Enter year: "); int bikeYear = scanner.nextInt(); System.out.print("Does it have a carrier? (true/false): "); boolean hasCarrier = scanner.nextBoolean(); scanner.nextLine(); // Consume newline bikeInventory.put(bikeModel, new Bike(bikeMake, bikeModel, bikeYear, hasCarrier)); System.out.println("Bike added successfully."); break; case "display car": System.out.print("Enter car model: "); String carToDisplay = scanner.nextLine(); if (carInventory.containsKey(carToDisplay)) { carInventory.get(carToDisplay).display(); } else { System.out.println("Car not found."); } break; case "display bike": System.out.print("Enter bike model: "); String bikeToDisplay = scanner.nextLine(); if (bikeInventory.containsKey(bikeToDisplay)) { bikeInventory.get(bikeToDisplay).display(); } else { System.out.println("Bike not found."); } break;
678 ·

信息流中的邻近内容

DDeloitte | COGNIZANT | IBM | CAPGEMINIWipro exam ✅✅✅ Contact: @MLCODER2DDeloitte | COGNIZANT | IBM | CAPGEMINIimport java.util.PriorityQueue; import java.util.Scanner; class ListNode { int val; ListNode next; ListNode(int val) { this.val = val; this.next = null; } } pub
这条消息
DDeloitte | COGNIZANT | IBM | CAPGEMINIcase "update car": System.out.print("Enter car model to update: "); String carToUpdate = scanner.nextLine(); if (carInventory.containsKey(caDDeloitte | COGNIZANT | IBM | CAPGEMINIIBM CIC ✅✅✅ Contact: @MLCODER2

来自搜索索引的公开信息流 ChatCrawler ——“公开 Telegram 的 Google”;随着该社群被抓取而更新。 时间为 UTC。

仅限公开内容,使用 Telegram 官方 API。 关于 · 常见问题 · 索引限制 · 移除页面 · 目录 · 搜索 · 计算方法