@Test public void should_return_zero_no_recharge() { Account account = new Account("1", BigDecimal.ZERO); assertEquals(BigDecimal.ZERO, account.balance()); }
public BigDecimal balance() { return activities.stream() .map(AccountActivity::getAmount) .reduce(initialBalance, BigDecimal::add); }
Account { public BigDecimal balance() { return activities.stream() .map(AccountActivity::getAmount) .reduce(initialBalance, BigDecimal::add); } }
Account { public BigDecimal balance() { return activities.stream() .map(AccountActivity::getAmount) .reduce(initialBalance, BigDecimal::add); } Account(String number, BigDecimal initialBalance); }
Account { public BigDecimal balance() { return activities.stream() .map(AccountActivity::getAmount) .reduce(initialBalance, BigDecimal::add); } Account(String number, BigDecimal initialBalance); String getNumber(); List<AccountActivity> getActivities(); BigDecimal balance(); void recharge(Recharge recharge); boolean consume(BigDecimal value); }
Account { public BigDecimal balance() { return activities.stream() .map(AccountActivity::getAmount) .reduce(initialBalance, BigDecimal::add); } Account(String number, BigDecimal initialBalance); String getNumber(); List<AccountActivity> getActivities(); BigDecimal balance(); void recharge(Recharge recharge); boolean consume(BigDecimal value);  }