Just make a new object and use the method setName(name).
A new object within the class I have would be breaking the rules my prof. told us though (at least that's what the paper says).
The idea is that a customer can make one of three accounts.
[X] Regular
[X] Savings
[X] Current/checking
Account. I need to be able to make multiple or at least one of each and store them in a array. All of these accounts are being accessed by another named Bank (I know it gets a bit confusing but theirs a BankAccount and Bank class. Their different) so would you mean to make a new object within Bank or one of the others? If your saying to mod the constructors then no go.
I basically have only these two to work with:
public BankAccount() {
//NO ARGUMENT CONSTRUCTOR
accountId = (int) (Math.random() * 9000) + 1000;
}
public BankAccount(double accountBalance) { // ONE ARGUMENT CONSTRUCTOR
accountId = (int) (Math.random() * 9000) + 1000;
//setAccountBalance(accountBalance);
}
Then I need to be able to close them using the arraylist by finding the name (of person) and the account ID. *huff*
Wow that is hard to type. As of now still working on getting the object to appear with the name.
EDIT: Specifically this:
if (userChoice == 1){
//Make a regular acct
System.out.println ("Okay lets make a regular account. Please Give me your name.");
String nameOfAccount = namingAccount.nextLine();
//HOW TO NAME THE ACCOUNT AND SEND IT TO THE bankAccounts
//BankAccount.setName(nameOfAccount);
BankAccount = new BankAccount();
}
Do I make the account with a no arg constructor and then just name it? But then I run into the problem of 'what if' I need to make another of these types? Won't that confuse the array/make it harder to find when looking for it?