Skip to content

Commit 2fdc902

Browse files
author
calvin
committed
feat: modified Check.java file to address Pull Request concerns
1 parent f989760 commit 2fdc902

File tree

1 file changed

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

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class Check {
77

88
private final String checkNumber;
99
private final double amount;
10-
private final CheckingAccount account;
10+
private final Account account;
1111
private boolean isVoided = false;
1212

1313
/**
@@ -17,10 +17,13 @@ public class Check {
1717
* @param amount The amount of the check.
1818
* @param account The account the check is drawn on.
1919
*/
20-
public Check(String checkNumber, double amount, CheckingAccount account) {
20+
public Check(String checkNumber, double amount, Account account) {
2121
if (amount < 0) {
2222
throw new IllegalArgumentException("Check amount must be positive");
2323
}
24+
if (!(account instanceof CheckingAccount)) {
25+
throw new IllegalArgumentException("Checks can only be drawn from checking accounts");
26+
}
2427
this.checkNumber = checkNumber;
2528
this.amount = amount;
2629
this.account = account;

0 commit comments

Comments
 (0)