简单Java停车场管理系统
我对Java有点生疏,很久没有编写过这样的程序了。我正在尝试创建一个简单的停车场管理程序,并实现以下类Vehicle和子类car、Van、Motorbike(这些扩展了车辆类别。车辆类别应包含有关车门数量和颜色的信息。货车类别应包含有关货车货运量的信息。摩托车类别应包含有关发动机尺寸的信息。程序应允许将车辆添加到停车场、删除车辆和打印当前停放车辆的列表,并给出停放车辆是汽车、自行车还是货车的信息。我已经设计了所有类别。但是,我对用户在这方面的输入有问题。添加车辆时,应允许用户输入汽车、自行车或货车型号、车牌、车辆颜色以及车门数量。以及am应在选择相应的菜单选项时打印信息。请您看看我迄今为止的代码,任何帮助都将不胜感激。我的问题是让用户输入所有要求的信息简单Java停车场管理系统,java,Java,我对Java有点生疏,很久没有编写过这样的程序了。我正在尝试创建一个简单的停车场管理程序,并实现以下类Vehicle和子类car、Van、Motorbike(这些扩展了车辆类别。车辆类别应包含有关车门数量和颜色的信息。货车类别应包含有关货车货运量的信息。摩托车类别应包含有关发动机尺寸的信息。程序应允许将车辆添加到停车场、删除车辆和打印当前停放车辆的列表,并给出停放车辆是汽车、自行车还是货车的信息。我已经设计了所有类别。但是,我对用户在这方面的输入有问题。添加车辆时,应允许用户输入汽车、自行车或货
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);
}
}
getDetails