Skip to content

Commit e189f72

Browse files
author
AmiyahJo
committed
feat: adds accountNumber tracked in audit log and money order records transaction
1 parent f3df9ad commit e189f72

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/AuditLog.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ public AuditLog() {
1010
logEntries = new ArrayList<>();
1111
}
1212

13-
public void logTransaction(String message, double amount, String type) {
14-
String logEntry = String.format("Transaction: %s | Amount: %.2f | Type: %s", message, amount, type);
13+
public void logTransaction(String accountNumber, String message, double amount, String type) {
14+
String logEntry = String.format("Account: %s | Transaction: %s | Amount: %.2f | Type: %s", accountNumber, message, amount, type);
1515
logEntries.add(logEntry);
1616
System.out.println(logEntry);
1717
}
18+
19+
public List<String> getLogEntries() {
20+
return logEntries;
21+
}
1822
}

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/MoneyOrder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public MoneyOrder(CheckingAccount sourceAccount, double amount, AuditLog auditLo
1212

1313
sourceAccount.withdraw(amount);
1414

15-
auditLog.logTransaction(sourceAccount.getAccountNumber(), -amount, "MoneyOrder");
15+
auditLog.logTransaction(sourceAccount.getAccountNumber(), "MoneyOrder created", -amount, "MoneyOrder");
1616
}
1717

1818
public CheckingAccount getSourceAccount() {

0 commit comments

Comments
 (0)