0
我有兩個類。我試圖讓:客戶Java輸入條件
-The電話號碼不是空白的,是10個字符
否則重新進入
-The車輛數爲1和10(1和10包括)之間
否則重新輸入
-The燃料箱的數目只能是(2,4,8,10,15,20)
否則重新輸入
我不知道如何讓電話號碼= 10位數字。車輛不止一次輸入(1-10)以外的值後,跳到油箱的數量。輸入除(2,4,8,10,15,20)以外的值後相同。我究竟做錯了什麼?幫助表示讚賞。謝謝。代碼
VehicleApp.Java段
public static void main(String[] args) {
String firstname = JOptionPane.showInputDialog("Enter your first name");
while (firstname.equals("")){
firstname = JOptionPane.showInputDialog("Enter your first name");
}
String lastname = JOptionPane.showInputDialog("Enter your last name");
while (lastname.equals("")){
lastname = JOptionPane.showInputDialog("Enter your last name");
}
String phone = JOptionPane.showInputDialog("Enter your phone");
while (phone.equals("")){
phone = JOptionPane.showInputDialog("Enter your phone");
}
int nbrVehicles = Integer.parseInt(JOptionPane.showInputDialog("Enter number of vehicles"));
if (nbrVehicles < 1 || nbrVehicles > 10){
JOptionPane.showInputDialog("Enter number of vehicles");
}
int nbrTanks = Integer.parseInt(JOptionPane.showInputDialog("Enter number of tanks"));
if (nbrTanks != 2 || nbrTanks != 4 || nbrTanks != 8 || nbrTanks != 10 || nbrTanks != 15 || nbrTanks != 200){
JOptionPane.showInputDialog("Enter number of tanks");
}
VehicleFactory vehicleObject = new VehicleFactory();
vehicleObject.HayloFactory(firstname, lastname, phone, nbrVehicles, nbrTanks);
vehicleObject.calcFuelTankCost();
vehicleObject.calcManufacturingCost();
vehicleObject.calcSubtotal();
vehicleObject.calcTax();
vehicleObject.calcTotal();
vehicleObject.getSummary();
}
}