File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -60,15 +60,21 @@ public void depositFunds(String accountNumber, double amount) {
6060 */
6161 public void depositFunds (String accountNumber , Check check ) {
6262 Account account = getAccountOrThrow (accountNumber );
63- check .depositFunds (account );
64- auditLog .logDeposit (accountNumber , check .getAmount ());
63+ if (!(account instanceof CheckingAccount )) {
64+ throw new IllegalArgumentException ("Checks can only be deposited into checking accounts" );
65+ }
66+ double balanceBefore = account .getBalance ();
67+ check .depositFunds ((CheckingAccount ) account );
68+ double balanceAfter = account .getBalance ();
69+ double depositAmount = balanceAfter - balanceBefore ;
70+ auditLog .logDeposit (accountNumber , depositAmount );
6571 }
6672
6773 /**
6874 * Withdraws funds from an account.
6975 *
70- * @param accountNumber
71- * @param amount
76+ * @param accountNumber The account number.
77+ * @param amount The amount to withdraw.
7278 */
7379 public void withdrawFunds (String accountNumber , double amount ) {
7480 Account account = getAccountOrThrow (accountNumber );
You can’t perform that action at this time.
0 commit comments