22
33import com .codedifferently .lesson17 .bank .exceptions .CheckVoidedException ;
44
5- /** Represents a check. */
65public 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