@@ -7,7 +7,7 @@ public class Check {
77
88 private final String checkNumber ;
99 private final double amount ;
10- private final Account account ;
10+ private final CheckingAccount account ;
1111 private boolean isVoided = false ;
1212
1313 /**
@@ -17,25 +17,22 @@ 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 , Account account ) {
20+ public Check (String checkNumber , double amount , CheckingAccount 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- }
2724 this .checkNumber = checkNumber ;
2825 this .amount = amount ;
2926 this .account = account ;
3027 }
3128
3229 /**
33- * Gets the amount of the check.
30+ * Gets the voided status of the check.
3431 *
35- * @return The amount .
32+ * @return True if the check is voided, and false otherwise .
3633 */
37- public double getAmount () {
38- return amount ;
34+ public boolean getIsVoided () {
35+ return isVoided ;
3936 }
4037
4138 /** Voids the check. */
@@ -48,13 +45,10 @@ public void voidCheck() {
4845 *
4946 * @param toAccount The account to deposit the check into.
5047 */
51- public void depositFunds (Account toAccount ) {
48+ public void depositFunds (CheckingAccount toAccount ) {
5249 if (isVoided ) {
5350 throw new CheckVoidedException ("Check is voided" );
5451 }
55- if (!(toAccount instanceof CheckingAccount )) {
56- throw new IllegalArgumentException ("Checks can only be deposited into checking accounts" );
57- }
5852 account .withdraw (amount );
5953 toAccount .deposit (amount );
6054 voidCheck ();
0 commit comments