Storyboard GroupAccountStoryboard1
Check: Groupaccount person set size should now be 1 actual 1
We call updateBalances() to compute the correct balances.
g1.updateBalances();
Now see updateBalances() as code:
public void updateBalances( ) { // compute share double share = totalPurchase / this.getPersons().size(); for (Person person : this.getPersons()) { double personExpenses = person.getItem().getValue().sum(); person.setBalance(personExpenses - share); } Assert.assertEquals("Balance should sum up to zero", 0.0, this.getPersons().getBalance().sum(), 0.00001); }
The effects of executing updateBalances() is shown in:
Check: Balance for Albert is now 5.0 +-1.0E-4 actual 5.0
Check: The sum of all balances is 0.0 +-1.0E-4 actual 0.0
Check: Found one person with name Albert 1.0 +-1.0E-4 actual 1.0
Check: Albert has name Albert true
Persons that have bought at least one item: (Albert 5.0, Nina -4.0, Artjom -1.0)