public class Account {
- private TransactionRepository transactionRepository;
+ private final TransactionRepository transactionRepository;
+ private final StatementPrinter statementPrinter;
- public Account(TransactionRepository transactionRepository) {
+ public Account(TransactionRepository transactionRepository,
+ StatementPrinter statementPrinter) {
this.transactionRepository = transactionRepository;
+ this.statementPrinter = statementPrinter;
}
public void deposit(int amount) {
}
public void printStatement() {
+ statementPrinter.print(transactionRepository.allTransactions());
}
}
// Acceptance test is using the real repository because the acceptance test
// is testing the system as a whole. We are just mocking the external world (the Console)
TransactionRepository transactionRepository = new TransactionRepository();
- account = new Account(transactionRepository);
+ StatementPrinter statementPrinter = new StatementPrinter();
+ account = new Account(transactionRepository, statementPrinter);
}
@Test public void