私はJavaでちょっと錆びました。このようなものは何年もプログラムしていません。私は単純な駐車場マネージャプログラムを作成し、次のクラスを実装しようとしています。Vehicle and Sub classes Car、Vanバイククラス(車クラスには車のドア数と色に関する情報が含まれています)Vanクラスにはバンの貨物量に関する情報が含まれている必要があります。クラスバイクにはエンジンに関する情報が必要ですこのプログラムでは、駐車場に車両を追加したり、車両を削除したり、現在駐車している車両のリストを印刷したり、駐車している車両が自転車やバンであれば情報を提供することができます。ユーザーはこれを入力します。車を追加する際には、車のバイクまたはバンモデル、登録プレート、車両の色、nドアの数。対応するメニューオプションが選択されると、プログラムは情報を表示する必要があります。あなたは私がこれまでに持っているコードを見てください、どんな助けも大いに感謝されるでしょうか?私が持っている問題は、ユーザーにすべての要求された情報を入力させることです。シンプルなJavaカーパーク管理システム
public class Vehicle {
private String carBrand;
private String regPlate;
// default constructor
public Vehicle() {
}
// constructor
public Vehicle(String carBrand, String regPlate) {
this.carBrand = carBrand;
this.regPlate = regPlate;
}
//getters
public String getCarBrand() {
return carBrand;
}
public String getRegPlate() {
return regPlate;
}
//setters
public void setCarBrand(String carBrand) {
this.carBrand = carBrand;
}
public void setColor(String regPlate) {
this.regPlate = regPlate;
}
}
...
public class Main {
public static void main(String[] args) {
CarParkManager myCarPark = new CarParkManager();
Scanner input = new Scanner(System.in);
int menu;
String model;
do {
System.out.println("WELCOME TO PARKING MANAGEMENT");
System.out.println("1: To Park Vehicle");
System.out.println("2: To Departure");
System.out.println("3: Show All Perked Vehicles");
System.out.println("0: To Exit");
System.out.print("Enter your choice: ");
menu = input.nextInt();
System.out.println();
switch (menu) {
case 1: {
String vType;
System.out.println("Please choose The Vehicle type");
System.out.println("C = Car");
System.out.println("B = Motorbike");
System.out.println("V = VAN");
vType = input.next();
if (vType.equals("C")) {
System.out.println("Enter Model");
model = input.next();
System.out.println("Enter Colour");
String colour = input.next();
System.out.println("Enter Reg Plate");
String regPlate = input.next();
System.out.println("Door Number");
int doorNumber = input.nextInt();
} else if (vType.equals("B")) {
} else if (vType.equals("V")) {
}
break;
}
case 2: {
break;
}
case 3: {
System.out.println("List of All Parked Vehicles : ");
myCarPark.printParkedVehicleDetails();
break;
}
case 0: {
System.out.println("\nThank you!\n");
break;
}
default: {
System.out.println("Invalid option!\n");
break;
}
}
} while (menu != 0);
}
}