Мне был предоставлен следующий код моего профессора.Если код выписки номер
public static void main(String[] args) {
Customer customer;
Transaction transaction;
double withdrawalAmount = 0;
boolean finished = false;
while (finished == false)
{
// Menu Display and Get user input
int inputInt = 0;
while (inputInt == 0)
{
inputInt = displayMenuAndGetInput();
// if the input is out of range
if ((inputInt < 1) || (inputInt > 8))
{
System.out.println("\nThe input is out of range!");
System.out.println();
inputInt = 0;
}
} //end while
// switch to correspondence function
switch (inputInt)
{
case 1:
customer = createPersonalCustomer();
System.out.println("\nThe Personal customer has been created: \n" + newPC.toString());
customers.add(customer);
break;
case 2:
customer = createCommercialCustomer();
System.out.println("\nThe Commercial customer has been created: \n" + newCC.toString());
customers.add(customer);
break;
case 3:
transaction = recordTransaction();
if(transaction != null)
System.out.println("\nThe Transaction has been created: \n" + trans.toString());
else
System.out.println("\nThe ID could not be found.");
break;
case 4:
withdrawalAmount = makeWithdrawal();
if(withdrawalAmount > 0)
System.out.println("\nAmount withdrawn from this account: " + moneyFormat.format(acct.getMakeWithdrawal()) + "\n");
else
System.out.println("\nThe ID could not be found.");
break;
case 5:
displayCustomer();
break;
case 6:
displayCustomerSummary();
break;
case 7:
displayGrandSummary();
break;
case 8:
// exit
finished = true;
break;
default:
System.out.println("Invalid Input!");
break;
} // end switch
} // end while
}
Я должен принять следующий код
// Create a new Transaction
public static Transaction recordTransaction(){}
и сделать петлю, которая работает по следующему сценарию:
вводится идентификатор клиента, и если идентификатор клиента не совпадает в массиве генерируется ошибка, считываемая в случае 3, и отображается главное меню. Если идентификатор клиента действителен, пользователь вводит данные ввода ниже.
Ниже мой код
public static Transaction recordTransaction(){
System.out.println("Enter the customer ID to create the transaction > ");
long customerID = scan.nextLong();
for (Customer c : customers) {
if (c.getCustomerID() == customerID) {
if (trans != null) {
System.out.println("\nEnter the weight of gold > ");
Transaction.goldWt = scan.nextDouble();
System.out.println("\nEnter the weight of platinum > ");
Transaction.platinumWt = scan.nextDouble();
System.out.println("\nEnter the weight of silver > ");
Transaction.silverWt = scan.nextDouble();
}
}
return null;
}
Anywho, я запускаю это целый ряд способов и либо мой код будет принимать недопустимый и действительный идентификатор клиента, или он не будет принимать недопустимый или действительный идентификатор клиента , Я знаю, что я, вероятно, что-то не замечаю, и поэтому я отчаянно прошу помощи форума. У меня есть тенденции OCD, когда дело доходит до программирования, и это мой первый класс intro java, поэтому я не очень разбираюсь в языке. Я застрял в этом вопросе последние два дня. Пожалуйста помоги.
это имеет смысл. Я был под впечатлением, так как я уже звонил в транс, я не должен был повторять это снова. – ComplexVolcano
Непонятно, что вы подразумеваете под «принятием». «Ничего не принимает» означает, что вы получаете сообщение «Идентификатор не найден». независимо от идентификатора клиента, который вы предоставляете?
Вы должны указать код метода createPersonalCustomer(). – dotvav
Да, состояние выхода: «Идентификатор не найден». для любого идентификатора, который предоставляет. Я не следую вашему второму утверждению «Вы должны предоставить код для метода createPersonalCustomer()». – ComplexVolcano