Skip to content

Commit bf71953

Browse files
committed
made changes to the following files:
1 parent a02f3a8 commit bf71953

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed
Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.codedifferently.lesson17.bank;
22

3-
import com.codedifferently.lesson17.bank.exceptions.InsufficientFundsException;
43
import java.util.Set;
54

5+
import com.codedifferently.lesson17.bank.exceptions.InsufficientFundsException;
6+
67
/** Base class for all bank accounts. */
78
public abstract class BankAccount {
89
private String accountNumber;
@@ -14,18 +15,11 @@ public BankAccount(String accountNumber, Set<Customer> owners, double initialBal
1415
this.owners = owners;
1516
this.balance = initialBalance;
1617
}
17-
18-
public String getAccountNumber() {
19-
return accountNumber;
20-
}
21-
22-
public double getBalance() {
23-
return balance;
24-
}
25-
26-
public Set<Customer> getOwners() {
27-
return owners;
28-
}
18+
/**
19+
* Gets the account number.
20+
*
21+
* @return The account number.
22+
*/
2923

3024
public void withdraw(double amount) throws InsufficientFundsException {
3125
if (amount > balance) {
@@ -34,10 +28,19 @@ public void withdraw(double amount) throws InsufficientFundsException {
3428
balance -= amount;
3529
}
3630

37-
public void deposit(double amount) {
38-
if (amount <= 0) {
39-
throw new IllegalArgumentException("Deposit amount must be positive");
40-
}
41-
balance += amount;
42-
}
31+
/**
32+
* Deposits funds into the account.
33+
*
34+
* @param amount The amount to deposit.
35+
*/
36+
public void deposit(double amount) throws IllegalStateException {
37+
if (isClosed()) {
38+
throw new IllegalStateException("Cannot deposit to a closed account");
39+
}
40+
if (amount <= 0) {
41+
throw new IllegalArgumentException("Deposit amount must be positive");
42+
}
43+
balance += amount;
44+
}
45+
protected abstract boolean isClosed();
4346
}

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,7 @@ public Set<Customer> getOwners() {
4545
return owners;
4646
}
4747

48-
/**
49-
* Deposits funds into the account.
50-
*
51-
* @param amount The amount to deposit.
52-
*/
53-
public void deposit(double amount) throws IllegalStateException {
54-
if (isClosed()) {
55-
throw new IllegalStateException("Cannot deposit to a closed account");
56-
}
57-
if (amount <= 0) {
58-
throw new IllegalArgumentException("Deposit amount must be positive");
59-
}
60-
balance += amount;
61-
}
48+
6249

6350
/**
6451
* Withdraws funds from the account.

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.codedifferently.lesson17.bank;
22

33
import java.util.Set;
4+
import java.util.UUID;
45

56
/** Represents a savings account. */
67
public class SavingsAccount extends BankAccount {
@@ -17,4 +18,20 @@ public SavingsAccount(String accountNumber, Set<Customer> owners, double initial
1718
public void depositFunds(Check check) {
1819
throw new UnsupportedOperationException("Cannot withdraw from savings account.");
1920
}
21+
22+
public String getAccountNumber() {
23+
// TODO Auto-generated method stub
24+
throw new UnsupportedOperationException("Unimplemented method 'getAccountNumber'");
25+
}
26+
27+
public Map<UUID getOwners() {
28+
// TODO Auto-generated method stub
29+
throw new UnsupportedOperationException("Unimplemented method 'getOwners'");
30+
}
31+
32+
@Override
33+
protected boolean isClosed() {
34+
// TODO Auto-generated method stub
35+
throw new UnsupportedOperationException("Unimplemented method 'isClosed'");
36+
}
2037
}

0 commit comments

Comments
 (0)