Solution

AdditionPattern.java
public class AdditionPattern{
    private int current;
    private int move;
    
    public AdditionPattern(int current, int move){
        this.current=current;
        this.move=move;
    }
    public void next(){
        current+=move;
    }
    public void prev(){
        if(current>move){
            current-=move;
        }
    }
    public int currentNumber(){
        return current;
    }
}
Account.java
public class Account {
    private static int noAccount=0;
    private double balance;
    public Account(double b)
    {
        balance=b;
        noAccount+=1;
    }
    public int getAccountNumber() {
        return noAccount;
    }
    public void deposit(int m)
    {
        balance+=m;
    }
    public double getBalance()
    {
        return balance;
    }
    public void withdraw(double w)
    {
        if(balance>=w)
        {
            balance-=w;
        }
    }

    public boolean transferTo(Account otherAccount, double amount)
    {
        if(balance>=amount)
        {
            balance-=amount;
            otherAccount.balance+=amount;
            return true;
        }
        return false;
    }
}

Last updated