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 1
1
package com .codedifferently .lesson17 .bank ;
2
2
3
- import com .codedifferently .lesson17 .bank .exceptions .AccountNotFoundException ;
4
3
import java .util .HashMap ;
5
4
import java .util .Map ;
6
5
import java .util .Set ;
7
6
import java .util .UUID ;
8
7
8
+ import com .codedifferently .lesson17 .bank .exceptions .AccountNotFoundException ;
9
+
9
10
/** Represents a bank ATM. */
10
11
public class BankAtm {
11
12
13
+
12
14
private final Map <UUID , Customer > customerById = new HashMap <>();
13
15
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 ){
14
20
21
+ this .auditLog () = auditLog ;
22
+ this .currencyConverter () = currencyConverter ;
23
+ }
24
+
25
+
26
+
27
+ }
15
28
/**
16
29
* Adds a checking account to the bank.
17
30
*
@@ -85,4 +98,4 @@ private CheckingAccount getAccountOrThrow(String accountNumber) {
85
98
}
86
99
return account ;
87
100
}
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