Bank Account Inheritance Assignment

Person Class

This page is an edited version of this (old) assignment

Constructor

  • public Person( String _name, int _age)

instance Variables

  • private String name
  • private int age

 Methods

  • public String  getName()
  • public boolean equals(Person  other) // assume that two objects with same age and name are equal

Account – Super Class

Static Variable(s)

  • static private  int nextAccountNum

Constructor

  • public Account( double_balance, Person _owner)

instance Variables

  • private int  accountNumber
  • protected  double  balance
  • protected  Person[] owners

 Methods

  • public int getAccountNumber()
  • public void deposit(double amount)
  • public double getCurrentBalance()
  • public  boolean withdraw(double amount); // returns  false if  amount > this.balance
  • public boolean equals(Account other)
  • public String toString()
  • public void addOwner(Person p)
  • public void removeOwner( Person p)
  • public Person[] getOwners()

CheckingAccount extends Account

  • instance Variables
    • private int checksWritten
  • Acessors and Mutators
    • void writeCheck( double amount) –> tries to call super.withDraw() as long as the balance is enough and records a new check number

SavingsAccount extends Account

  • instance variables
    • private double interestRate
    • double[]  dailyBalances

    static variables

    • public static final int MINIMUM_BALANCE=100; // this is the absolute minimum amount of money that must always be in the account
  • methods
    • public boolean withdraw(double amount) //@override the withdraw() method to ensure that currentBalance the never gets below MINIMUM_BALANCE
    • public void recordDailyBalance() // @ record current day’s balance by storing it in   dailyBalances

 

After you have completed this, work on the Bank runner class.