Monthly Archives: March 2015

Bank Runner Class

Bank Class

This is a modified version of this bank assignment

The responsibilities of this class are to

  • Methods
    • Person[] topAccountOwners(int number )
      • this method returns the  top number  owners with the greatest amount of cash in 1 account
    • ** boolean binarySearch( int accountNumber)  // this method should implement the binary search algorithm to determine if the account acct exists . Note for binary search to work, what must be true?
    • ** extra credit  Account[] sortByAccountId()
      •   this method returns an array of Accounts sorted by amount in the account

 

 

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.