Skip to content

Commit 05b9e0a

Browse files
author
“Tezz03”
committed
feat: NewPR
1 parent 1e6771f commit 05b9e0a

File tree

1 file changed

+5
-11
lines changed
  • lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank

1 file changed

+5
-11
lines changed

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,27 @@
22

33
import com.codedifferently.lesson17.bank.exceptions.CheckVoidedException;
44

5-
/** Represents a check. */
65
public class Check {
76

87
private final String checkNumber;
98
private final double amount;
109
private final CheckingAccount account;
1110
private boolean isVoided = false;
12-
private final SavingsAccount savings;
1311

1412
/**
1513
* Creates a new check.
1614
*
1715
* @param checkNumber The check number.
1816
* @param amount The amount of the check.
19-
* @param account The account the check is drawn on. Because account is represents checking it could also represent savings.so if
20-
* we call saving account saving we should be able to throw the exception on the check.
17+
* @param account The account the check is drawn on.
2118
*/
22-
public Check(String checkNumber, double amount, CheckingAccount account, SavingsAccount savings) {
23-
if (checkNumber == null || checkNumber.isEmpty()) {
24-
throw new IllegalArgumentException("Check number cannot be null or empty");
25-
}
26-
if (amount < 0 ) {
19+
public Check(String checkNumber, double amount, CheckingAccount account) {
20+
if (amount < 0) {
2721
throw new IllegalArgumentException("Check amount must be positive");
2822
}
2923
this.checkNumber = checkNumber;
3024
this.amount = amount;
3125
this.account = account;
32-
this.savings = null;
3326
}
3427

3528
/**
@@ -50,8 +43,9 @@ public void voidCheck() {
5043
* Deposits the check into an account.
5144
*
5245
* @param toAccount The account to deposit the check into.
46+
* @throws Exception
5347
*/
54-
public void depositFunds(CheckingAccount toAccount) {
48+
public void depositFunds(BankAccount toAccount) throws Exception {
5549
if (isVoided) {
5650
throw new CheckVoidedException("Check is voided");
5751
}

0 commit comments

Comments
 (0)