Skip to content

Commit

Permalink
Update SavingsAccount.java
Browse files Browse the repository at this point in the history
  • Loading branch information
JitseGoutbeek authored Jun 28, 2024
1 parent b229558 commit de336b0
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@ public class SavingsAccount {
private Money balance = new Money();
private CheckingAccount counterAccount = new CheckingAccount();

public void setaccountnumber(CheckingAccount account) {
this.counteraccount = account;
}
public Transfer makeTransfer(Money amount)
throws BusinessException {
// 1. Assuming result is 9-digit bank account number, validate 11-test:
int sum = 0;
for (int i = 0; i < counterAccount.length(); i++) {
char character = counterAccount.charAt(i);
int characterValue = Character.getNumericValue(character);
sum = sum + (9 - i) * characterValue;
}
if (sum % 11 == 0) {
// 3. Look up counter account and make transfer object:
CheckingAccount acct = Accounts.findAcctByNumber(counterAccount);
Transfer result = new Transfer(this, acct, amount);
return result;
} else {
Expand Down

0 comments on commit de336b0

Please sign in to comment.