File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments