File tree Expand file tree Collapse file tree 3 files changed +48
-2
lines changed
lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank Expand file tree Collapse file tree 3 files changed +48
-2
lines changed Original file line number Diff line number Diff line change 1+ package com .codedifferently .lesson17 .bank ;
2+
3+ public class AuditLog {
4+ private final List <String > entries = new ArrayList <>();
5+
6+ public void record (String message ) {
7+ entries .add (LocalDateTime .now () + " - " + message );
8+ }
9+
10+ public List <String > getEntries () {
11+ return entries ;
12+ }
13+ }
14+
15+
Original file line number Diff line number Diff line change 11package com .codedifferently .lesson17 .bank ;
22
3- import com .codedifferently .lesson17 .bank .exceptions .AccountNotFoundException ;
43import java .util .HashMap ;
54import java .util .Map ;
65import java .util .Set ;
76import java .util .UUID ;
87
8+ import com .codedifferently .lesson17 .bank .exceptions .AccountNotFoundException ;
9+
910/** Represents a bank ATM. */
1011public class BankAtm {
1112
13+
1214 private final Map <UUID , Customer > customerById = new HashMap <>();
1315 private final Map <String , CheckingAccount > accountByNumber = new HashMap <>();
16+ private final AuditLog auditLog ();
17+ private final CurrencyConverter currencyConverter ();
18+
19+ public BankAtm (AuditLog auditLog , CurrencyConverter currencyConverter ){
1420
21+ this .auditLog () = auditLog ;
22+ this .currencyConverter () = currencyConverter ;
23+ }
24+
25+
26+
27+ }
1528 /**
1629 * Adds a checking account to the bank.
1730 *
@@ -85,4 +98,4 @@ private CheckingAccount getAccountOrThrow(String accountNumber) {
8598 }
8699 return account ;
87100 }
88- }
101+
Original file line number Diff line number Diff line change 1+ package com .codedifferently .lesson17 .bank ;
2+
3+ public class CurrencyConverter {
4+ private final Map <Currency , Double > exchangeRates ;
5+
6+ public CurrencyConverter () {
7+ exchangeRates = new HashMap <>();
8+ exchangeRates .put (Currency .USD , 1.0 );
9+ exchangeRates .put (Currency .EUR , 1.1 );
10+ exchangeRates .put (Currency .GBP , 1.3 );
11+
12+ }
13+
14+ public double convert (double amount , Currency from , Currency to ) {
15+ double usd = amount / exchangeRates .get (from );
16+ return usd * exchangeRates .get (to );
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments