Could you give a bit more context/description about app. From this quote I'm a bit puzzled who is the one who creating an account. If the bank, then don't understand the part "depending on the bank they are using".Nicolette Locker wrote:this method is meant to create a bank account number for the customer depending on the bank they are using ( there are two different banks).
Upon the bank creation you should increment bankNumCounter which is static (from previous, to which is going to be a current number you need to assign to a bank you're creating)
It would do that if String wouldn't be null at that point, but the issue isn't exactly that, issue is, that bankNumber is an instance variable, where other bank accounts have their own copies of that, so they always are null until assigned to some value, hence you wouldn't identify which next bank number supposed to be.Nicolette Locker wrote:I guess I was under the impression that parseInt changed a String to an int.
Yes, you got an idea. However, check the comment at the same line, it isn't doing what you wrote.Nicolette Locker wrote: more like this?
"The bankNumber is assigned to a Bank when it is constructed, and must be unique for each bank.
Hint: You may assume that the first bank number is assigned the value from a static variable with an initial value of 1, and each time a new Bank is created, the static variable is incremented by 1.
So you need same for account number as Campbell suggested. But these numbers should be unique within a bank. In different words, bank A and bank B can have accounts with same account numbers, but they then to be unique internally.The account number for every account from a particular Bank should be created by that Bank, and should be unique to that Bank.
Hint: In the Bank class, you can use an additional field that keeps track of the last account number used, where the first account is assigned the number 1, and each time a new account is created, the variable is incremented by 1."
Nicolette Locker wrote:
...but my real question here is, what is the class BankAccount doing at the beginning of the method, and what is the class Customer set as a parameter?
So you need same for account number as Campbell suggested. But these numbers should be unique within a bank. In different words, bank A and bank B can have accounts with same account numbers, but they then to be unique internally.
Somebody: "Hey, what's your bank's name?"
You: "Let's see, I'm going to make me a Bank first... then I'm going to ... wait, what?"
Somebody: (thinking) "What in the ... ?"