I need to process my array list and calculate the total that is take from each account balance.
I can't have another data structure as per homework.
First though was to loop over the list and
This does not work as the previous total is added to the next customer.
A potential solution would be to add an accountKey to the Customer and Account, so I can have a constant in both lists, to check if they match and calculate the total.
Maybe that would stop the addition of balance to the next customer.
I don't think that is a go, tho.
What does it mean for an Account to have a total? Doesn't the balance represent the total? It seems like what you are looking for is a Customer total which is a total of all of the balances in all the accounts that the customer has.
thank you, I understand now where I was wrong.
A customer is one and accounts are many.
Still, if I would have wanted to have a variable in each account, as "totalForAllAcounts", how would that be achievable?
Account: details of the account + new field totalOfAllAccounts