I have a banking program with an enter customer, and balance method. The method adds a String and a double to my accounts ArrayList, if the name Sam for example is inputted, I want to stop that name from being inputted again, as currently it creates two separate Strings and balances for Sam and when withdrawing/depositing both are modified since I check the name/String to get the right account.
class Bank {
ArrayList<Account> accounts = new ArrayList<Account>();
public void enterCustomers() {
String name = "";
double balance;
System.out.println("Enter customer names or q to quit entering names");
while (true) {
name = MyConsole.getString("Enter a customer name: ");
if (name.equals("q")) {
break;
}
balance = MyConsole.getDouble("Enter opening balance: ");
accounts.add(new Account(name, balance));
}
}