Question: Please help with explaining and showing how this below switch/case shall communicate with another method in another class and write the code down for that
Please help with explaining and showing how this below switch/case shall
communicate with another method in another class and
write the code down for that method in the answer, how that method will look.
The problem is that the user can type in same ssn by mistake as it is now,
I like to have a check so that is not possible.
Thanks!
switch (choice) {
case 1: {
while(true) {
System.out.print("Enter customer unique ssn: ");
ssn = sc.nextInt();
if(bank.checkSsn(ssn)){
break;
}
else{
System.out.println("Ssn already exist, Please enter a unique ssn:");
}
}
System.out.print("Enter customer name: ");
sc.nextLine();
String name = sc.nextLine();
Customer customer = new CustomerBuilder().setSsn(ssn).setName(name).createCustomer();
Bank.addCustomer(customer);
System.out.println(" Customer added successfully with uniquely ssn: " + customer.getSSN());
}
break;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
