Skip to content

Commit 4d25713

Browse files
committed
Chore: Adds JavaDoc to AuditLog and SavingsAccount
1 parent c36cc92 commit 4d25713

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,40 @@
55
import org.apache.logging.log4j.LogManager;
66
import org.apache.logging.log4j.Logger;
77

8+
/**
9+
* The {@code AuditLog} class is responsible for logging important events in the banking system. It
10+
* uses the Log4j logging framework to log messages at different levels.
11+
*/
812
public class AuditLog {
13+
914
private static final Logger logger = LogManager.getLogger(AuditLog.class.getName());
1015
private final List<String> logEntries = new ArrayList<>();
1116

17+
/**
18+
* Logs a message at the INFO level and adds it to the internal list of log entries.
19+
*
20+
* @param message
21+
*/
1222
public void log(String message) {
1323
logger.info(message);
1424
logEntries.add(message);
1525
}
1626

27+
/**
28+
* Logs an error message at the ERROR level and adds it to the internal list of log entries.
29+
*
30+
* @param message
31+
*/
32+
public void logError(String message) {
33+
logger.error(message);
34+
logEntries.add(message);
35+
}
36+
37+
/**
38+
* Returns the list of log entries.
39+
*
40+
* @return A list of log entries
41+
*/
1742
public List<String> getLogEntries() {
1843
return logEntries;
1944
}

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,39 @@
22

33
import java.util.Set;
44

5+
/**
6+
* The {@code SavingsAccount} class represents a savings account in a banking system. It extends the
7+
* {@code CheckingAccount} class and provides additional functionality specific to savings accounts.
8+
*/
59
public class SavingsAccount extends CheckingAccount {
610

11+
/**
12+
* Constructs a new SavingsAccount with the specified account number, owners, and balance.
13+
*
14+
* @param accountNumber
15+
* @param owners
16+
* @param balance
17+
*/
718
public SavingsAccount(String accountNumber, Set<Customer> owners, double balance) {
819
super(accountNumber, owners, balance);
920
}
1021

22+
/**
23+
* Gets the HashCode of the account number.
24+
*
25+
* @return The hash code of the account number.
26+
*/
1127
@Override
1228
public int hashCode() {
1329
return getAccountNumber().hashCode();
1430
}
1531

32+
/**
33+
* Checks if this SavingsAccount is equal to another object.
34+
*
35+
* @param obj The object to compare with.
36+
* @return true if the objects are equal, false otherwise.
37+
*/
1638
@Override
1739
public boolean equals(Object obj) {
1840
if (obj instanceof SavingsAccount other) {
@@ -24,11 +46,22 @@ && getBalance() == other.getBalance()
2446
return false;
2547
}
2648

49+
/**
50+
* Will throw and exception if the user attempt to make a withdrawl while under the instance of
51+
* SavingsAccount.
52+
*
53+
* @param amount The amount to deposit.
54+
*/
2755
@Override
2856
public void withdraw(double amount) {
2957
throw new RuntimeException("Cannot withdraw from a savings account using a check");
3058
}
3159

60+
/**
61+
* Returns a string representation of the SavingsAccount.
62+
*
63+
* @return A string representation of the SavingsAccount.
64+
*/
3265
@Override
3366
public String toString() {
3467
return "SavingsAccount"

0 commit comments

Comments
 (0)