2
2
3
3
import com .codedifferently .lesson17 .bank .exceptions .CheckVoidedException ;
4
4
5
- /** Represents a check. */
6
5
public class Check {
7
6
8
7
private final String checkNumber ;
9
8
private final double amount ;
10
9
private final CheckingAccount account ;
11
10
private boolean isVoided = false ;
12
- private final SavingsAccount savings ;
13
11
14
12
/**
15
13
* Creates a new check.
16
14
*
17
15
* @param checkNumber The check number.
18
16
* @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.
21
18
*/
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 ) {
27
21
throw new IllegalArgumentException ("Check amount must be positive" );
28
22
}
29
23
this .checkNumber = checkNumber ;
30
24
this .amount = amount ;
31
25
this .account = account ;
32
- this .savings = null ;
33
26
}
34
27
35
28
/**
@@ -50,8 +43,9 @@ public void voidCheck() {
50
43
* Deposits the check into an account.
51
44
*
52
45
* @param toAccount The account to deposit the check into.
46
+ * @throws Exception
53
47
*/
54
- public void depositFunds (CheckingAccount toAccount ) {
48
+ public void depositFunds (BankAccount toAccount ) throws Exception {
55
49
if (isVoided ) {
56
50
throw new CheckVoidedException ("Check is voided" );
57
51
}
0 commit comments