Tag Archives: abstract class

Account Abstract Class Assignment

This is the first part of a 2 part project.

Person Class

Constructor

  • public Person( String _name , int _age )

instance Variables

  • private String name
  • private int age

 Methods

  • public String  getName()
  • public int compareTo(Person other) { return this.age – other.age; }

account_with_person2_with_arrow

Account – Abstract Super Class

Static Variable(s)

  • private static int nextAccountNum
  • private static int parentCompanyCode = 12810  ;

instance Variables

  • private int  accountNumber// first account number should be 1 
  • protected  double  balance
  • protected  ArrayList<Person> owners

Constructor

  • public Account( double _balance, Person _owner)  // add _owner to ArrayList  owners

Methods

  • public static int getParentCode()
  • public int getAccountNumber()
  • public void deposit(double amount)
  • public double getCurrentBalance()
  • public abstract  boolean withdraw(double amount)
  • public boolean equals(Account other)  // are the unique account numbers equals ?
  • public String toString() Output should follow the conventions we have discussed. I will be testing for formatting like this :screenshot.41
  • public int comparesTo(Account other) { return this.accountNumber- other.accountNumber }  (Note that this method has an ‘s‘ )
  • public void addOwner(Person p)  //adds P to the ArrayList of owners
  • public ArrayList<Person> getOwners()  //  returns the ArrayList of owners
  • public Person remove( Person p) // this emulates the ArrayList’s remove() method (link) . Remember that that method removes the object and then returns the removed object. In this case, you should remove Person P  from the ArrayList of owners

  • CheckingAccount extends Account
  • This class has to do certain things. You can decide the best way to do it. This class should have a way to
    • attempt to withdraw money by writing a check. Every check should have a ‘check number’, which should be an integer. The lowest permissible value for a check number is 100 .  
    • public int writeCheck(double amount) // @ returns the check number of the written check 
    • public boolean cancelCheck(int checkNumber)
      • be able to cancel checks and keep track of the check numbers that have been cancelled
      • when a check is cancelled, the amount associated with that check is added back onto the balance.
      • return true  if checkNumber  is a valid check number; false  otherwise.
  • One solution
    • every time you write a check, you need a new check “#”
    • writeCheck( double amount) – > tries to call this.withdraw(double amount)  . You can then use ArrayLists to store check numbers, associated check amounts , things like that

SavingsAccount extends Account

  • instance variables
    • private double interestRate //  //@ assumes that interest rate is not in decimal format i.e. 1.7 not .017
    • private ArrayList<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 updateInterestRate(double newRate) //updates the interestRate
      • public void recordDailyBalance()  // @ record current day’s balance by storing current balance in dailyBalances  .
      • public ArrayList<Double> getDailyBalances()  // @ return dailyBalances .
      • public double projectBalance(double timeInYears)  // use the compound interest formula .  Assume that the bank compounds the balance monthly. To learn more about how compound interest really works, click here .
        •   You will need to convert interest rate from something like 1.7%, as an example , to 0.017
      • public  void updateInterestPayment()  // @ once a month update account based on average daily balances and interest rate.

    *calculate the average monthly balance
    * multiply balance by the interest rate (remember this must be converted to decimal)
    * add that interest back onto the balance

  • public double getInterestRate() 
  • public String toString() Output should follow the conventions we have discussed. I will be testing for formatting like this : SavingsAccount_toString_v2

CertificateOfDeposit extends SavingsAccount

instance Variables

  • public static final  double EARLY_WITHDRAW_PENALTY= 200 .

 Methods

  • public boolean withdraw(double amount , boolean isEarly )  //@override the withdraw()  and applies penalty to balance

 

Tester file :

[pastacode lang=”java” manual=”import%20java.util.ArrayList%3B%0A%0Apublic%20class%20Tester%20%7B%20%0A%20%20%20%20boolean%20verbose%20%3D%20false%3B%20%2F%2Fset%20to%20true%20for%20some%20expanded%20occasional%20error%20messages%0A%0A%0A%20%20%20%20public%20Tester()%20%7B%0A%20%20%20%20%20%20%20%20p2(%22Begin%20Testing%22)%3B%20%20%20%20%0A%20%20%20%20%20%20%20%20p2(%22Version%204%22)%3B%20%20%20%20%0A%20%20%20%20%20%20%20%20p2(%22set%20variable%20verbose%20to%20true%20if%20you%20want%20some%20occasional%20extra%20tips%20on%20errors%22)%3B%20%20%20%20%0A%09%09p2(%22********************************************************************%22)%20%3B%0A%09%09p2(%22********************************************************************%22)%20%3B%0A%20%20%20%20%20%20%20%20doTest()%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20public%20void%20doTest()%7B%0A%0A%20%20%20%20%20%20%20%20int%20correct%20%3D%200%3B%0A%20%20%20%20%20%20%20%20int%20wrong%20%3D%200%3B%0A%20%20%20%20%20%20%20%20Person%20tyler%20%3D%20new%20Person(%22tyler%22%2C%2018)%3B%0A%20%20%20%20%20%20%20%20Person%20joe%20%3D%20new%20Person(%22joe%22%2C%2018)%3B%0A%20%20%20%20%20%20%20%20Person%20jim%20%3D%20new%20Person(%22jim%22%2C%2017)%3B%0A%0A%20%20%20%20%20%20%20%20if(tyler.compareTo(joe)%20%3D%3D%200)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22error%20%40person%2C%20compareTo()%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if(jim.compareTo(joe)%20%3D%3D%20-1)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22error%20%40person%2C%20compareTo()%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if(joe.compareTo(jim)%20%3D%3D%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22error%20%40person%2C%20compareTo()%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if(%20joe.getName().equals(%22joe%22))%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22error%20%40person%2C%20getName()%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%0A%20%20%20%20%20%20%20%20CertificateOfDeposit%20a%20%3D%20new%20CertificateOfDeposit(tyler%2C%20120)%3B%0A%20%20%20%20%20%20%20%20double%20a_original_bal%20%3D%20a.getCurrentBalance()%3B%0A%20%20%20%20%20%20%20%20a.addOwner(joe)%3B%0A%20%20%20%20%20%20%20%20int%20a_num1%20%3D%20a.getAccountNumber()%20%3B%20%20%20%20%0A%09%09%0A%09%09%0A%0A%20%20%20%20%20%20%20%20if%20(a_num1%20!%3D%201%20)%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%20%20%20%20%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22First%20account%20’s%20id%20should%20be%20’1’%20%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%0A%0A%20%20%20%20%20%20%20%20CertificateOfDeposit%20a2%20%3D%20new%20CertificateOfDeposit(jim%2C%20120)%3B%0A%0A%0A%0A%0A%20%20%20%20if(a2.getAccountNumber()%20%3C%3D%20a_num1)%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%20%20%20%20%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22Unique%20account%20numbers%20not%20working%20correctly%20%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%0A%0A%20%20%20%20%20%20%20%20if%20(a.getOwners().size()%20!%3D%202)%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22addOwner()%20not%20working%20%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%20%20%20%20%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%0A%20%20%20%20%20%20%20%20a.remove(joe)%3B%0A%20%20%20%20%20%20%20%20if%20(a.getOwners().size()%20!%3D%201)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%20%3B%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22error%20%2C%20probably%20removeOwner()%20not%20working%20%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20Person%20owner%20%3D%20a.getOwners().get(0)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if(owner.getName().toLowerCase().equals(%22tyler%22))%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%20%3B%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p2(%22error%20%2C%20probably%20removeOwner()%20not%20working%20%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0A%20%20%20%20%20%20%20%20if(Math.abs(a_original_bal%20-%20120)%20%3E%200.000001)%0A%09%09%7B%0A%09%09p2%20(%22foo%20problem%20with%20setting%20%20balance%22)%3B%0A%09%09wrong%2B%2B%3B%0A%09%09%7D%0A%20%20%20%20%20%20%20%20else%20%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%0A%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20a.deposit(25)%3B%0A%20%20%20%20%20%20%20%20if(Math.abs(a.getCurrentBalance()%20-%20145)%20%3E%200.000001)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%20%20%20%20%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22problem%20with%20setting%20%20balance%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20Person%20rob%20%3D%20new%20Person(%22rob%22%2C%2018)%3B%0A%20%20%20%20%20%20%20%20CheckingAccount%20b%20%3D%20new%20CheckingAccount(rob%2C%20200)%3B%0A%20%20%20%20%20%20%20%20b.deposit(500)%3B%0A%20%20%20%20%20%20%20%20b.withdraw(450)%3B%0A%20%20%20%20%20%20%20%20if(%20b.equals(a))%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22Failed%20equals()%20test%20(Many%20things%20could%20cause%20this)%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%0A%20%20%20%20%20%20%20%20if(%20a.equals(a)%20%3D%3D%20false)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22Failed%20equals()%20test%20(Many%20things%20could%20cause%20this)%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%0A%0A%20%20%20%20%20%20%20%20double%20balanceNow%20%3D%20b.getCurrentBalance()%3B%0A%20%20%20%20%20%20%20%20int%20checkNum%20%3D%20b.writeCheck(4)%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20p2(%22checkNum%20%3A%20%22%20%2B%20checkNum)%3B%0A%20%20%20%20%20%20%20%20%20%20%20if(checkNum%20%3E%3D%20100)%20%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22error%2C%20Check%20Numbers%20cannot%20be%20lower%20than%20100%22)%20%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%20%20int%20check2Num%20%3D%20b.writeCheck(4)%3B%0A%20%20%20%20%20%20%20%20if(check2Num%20-%20checkNum%20%3D%3D%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22error%20involving%20checknumbers.%20Should%20increment%20by%201%22)%20%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20if(%20balanceNow%20-%20b.getCurrentBalance()%20%3D%3D%20%208)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22Error%20involving%20writing%20checks%20and%20balance…could%20be%20various%20problems%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if(verbose)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p2(%22%5Ct%20most%20likely%20your%20writeCheck()%20or%20withdraw()%20are%20the%20problem%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20balanceNow%20%3D%20b.getCurrentBalance()%20%3B%0A%20%20%20%20%20%20%20%20int%20check3Num%20%3D%20b.writeCheck(242.1)%3B%0A%0A%20%20%20%20%20%20%20%20if(check3Num%20-%20checkNum%20%3D%3D%202)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22error%20involving%20checknumbers.%20Should%20increment%20by%201%2Ceven%20if%20the%20check%20bounces!%22)%20%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20if(balanceNow%20%20%3D%3D%20b.getCurrentBalance())%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22Error%20involving%20bounced%20checks.%20You%20cannot%20withdrawal%20more%20than%20your%20current%20balance%22)%20%3B%0A%20%20%20%20%20%20%20%20p2(%22exiting%20testing%20program%22)%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0A%20%20%20%20%20%20%20%20boolean%20badChkNum%20%3D%20%20b.cancelCheck(50)%3B%0A%20%20%20%20%20%20%20%20if(badChkNum%20%3D%3D%20false)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%20%20%20%20%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22Error.%20cancelCheck%20on%20non%20existent%20check.%20Should%20return%20false%2C%20but%20didn’t%22)%20%3B%0A%20%20%20%20%20%20%20%20p2(%22exiting%20testing%20program%22)%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20int%20check4Num%20%3D%20b.writeCheck(100)%3B%0A%0A%0A%20%20%20%20%20%20%20%20b.cancelCheck(check4Num)%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20double%20balanceAferCancel%20%3D%20b.getCurrentBalance()%3B%0A%20%20%20%20%20%20%20%20if(%20balanceAferCancel%20%3D%3D%20242)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if(balanceAferCancel%20%3D%3D%20142)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p2(%22cancelCheck()%20did%20not%20update%20balance.%20You%20still%20have%20deducted%20the%20amount%20for%20the%20check%20that%20is%20now%20cancelled%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p2(%22error%20%2C%20could%20be%20various%20things%20but%20most%20likely%20relateing%20to%20cancelCheck()%2Fdeposit()%20%20%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%20%20%2F%2F%20if(balanceNow%20%20%3D%3D%20b.getCurrentBalance())%0A%20%20%20%20%20%20%20%20%2F%2F%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20else%0A%20%20%20%20%20%20%20%20%2F%2F%20%7B%0A%20%20%20%20%20%20%20%20%2F%2F%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20p2(%22Error%20involving%20bounced%20checks.%20You%20cannot%20withdrawal%20more%20than%20your%20current%20balance%22)%20%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20%7D%0A%0A%0A%20%20%20%20%20%20%20%20Person%20roochi%20%3D%20new%20Person(%22roochi%22%2C%2012)%3B%0A%20%20%20%20%20%20%20%20SavingsAccount%20c%20%3D%20new%20SavingsAccount(roochi%2C%20110)%3B%0A%20%20%20%20%20%20%20%20boolean%20allGood%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20if(c.getCurrentBalance()%3D%3D%20110)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20allGood%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22error%2C%20could%20be%20constructor%20or%20getCurrentBalance()%22)%20%3B%0A%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%0A%0A%0A%20%20%20%20%20%20%20%20c.withdraw(5)%3B%0A%20%20%20%20%20%20%20%20if(c.getCurrentBalance()%3D%3D%20105)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if(allGood%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p2(%22error%2C%20probably%20withdraw()%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p2(%22error%2C%20could%20be%20constructor%20or%20getCurrentBalance()%20%22)%20%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20boolean%20isNull%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20try%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20c.addOwner(tyler)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20catch(%20NullPointerException%20e)%7B%0A%20%20%20%20%20%20%20%20isNull%20%3D%20true%3B%20%20%20%20%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20if(isNull)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p2(%22Looks%20like%20owners%20arraylist%20is%20null%22)%3B%0A%20%20%20%20%20%20%20%20p2(%22exiting%20program%20now%2C%20fix%20nullpointer%20first%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%0A%0A%2F%2Fhere%20%0A%2F%2F%20public%20String%20toString()%0A%0A%0A%0A%0A%0A%20%20%20%20%20%20%20%20Person%20james%20%3D%20new%20Person(%22Jim%20Adams%20II%22%2C%2012)%3B%0A%20%20%20%20%20%20%20%20SavingsAccount%20jamesAcct%20%20%3D%20new%20SavingsAccount(james%20%2C%20666%20)%3B%0A%20%20%20%20%20%20%20%20jamesAcct.addOwner(new%20Person(%22Jane%20Adams%20%22%2C%2034)%20)%3B%0A%20%20%20%20%20%20%20%20jamesAcct.addOwner(new%20Person(%22Jim%20Adams%20Sr%22%2C%2035)%20)%3B%0A%20%20%20%20%20%20%20%20ArrayList%3CPerson%3E%20owners%20%3D%20jamesAcct.getOwners()%3B%0A%0A%0A%20%20%20%20%20%20%20%20boolean%20anotherNull%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20try%7B%0A%20%20%20%20%20%20%20%20jamesAcct.recordDailyBalance()%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20catch(NullPointerException%20e)%7B%0A%20%20%20%20%20%20%20%20anotherNull%20%3D%20true%20%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20if(anotherNull)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22NullPointer%20Exception%20Error%2C%20looks%20like%20you%20never%20initialized%20dailyBalances%20in%20SavingsAccount%22)%3B%0A%20%20%20%20%20%20%20%20p2(%22Exiting%20testing%20program%22)%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%0A%0A%20%20%20%20jamesAcct.updateInterestRate(3.3)%3B%0A%0A%20%20%20%20if(jamesAcct.getInterestRate()%20%3D%3D%203.3%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22error%2C%20probably%20re%3A%20updateInterestRate()%20%20or%20possibly%20getInterestRate()%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0A%20%20%20%20jamesAcct.recordDailyBalance()%3B%0A%20%20%20%20%0A%0A%20%20%20%20jamesAcct.deposit(22)%3B%0A%20%20%20%20jamesAcct.recordDailyBalance()%3B%0A%20%20%20%20jamesAcct.withdraw(100)%3B%0A%20%20%20%20jamesAcct.recordDailyBalance()%3B%0A%20%20%20%20jamesAcct.deposit(330)%3B%0A%20%20%20%20jamesAcct.recordDailyBalance()%3B%0A%0A%20%20%20%20%20ArrayList%3CDouble%3E%20%20dailyBalances%20%3D%20jamesAcct.getDailyBalances()%3B%20%0A%20%20%20%20%0A%20%20%20%20if(dailyBalances.get(0)%3D%3D%20666)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22error%20%40%20dailyBalances%20index%200%22)%3B%0A%20%20%20%20%20%20%20%20if(verbose)%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22%5Ct%5Ct%201st%20element%20of%20dailyBalances%20should%20be%20666.00%22)%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20p2(%22exiting%20testing%20program%2C%20fix%20daily%20balances%20first%22)%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0A%0A%20%20%20%20if(dailyBalances.get(1)%3D%3D%20666)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22error%20%40%20dailyBalances%20index%201%22)%3B%0A%20%20%20%20%20%20%20%20if(verbose)%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22%5Ct%5Ct%202nd%20element%20of%20dailyBalances%20should%20be%20666.00%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20if(dailyBalances.get(2)%3D%3D%20688)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22error%20%40%20dailyBalances%20index%202%22)%3B%0A%20%20%20%20%20%20%20%20if(verbose)%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22%5Ct%5Ct%203rd%20element%20of%20dailyBalances%20should%20be%20666.00%22)%20%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20if(dailyBalances.get(3)%3D%3D%20588)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22error%20%40%20dailyBalances%20index%203%22)%3B%0A%20%20%20%20%20%20%20%20if(verbose)%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22%5Ct%5Ct%204th%20element%20of%20dailyBalances%20should%20be%20588.00%22)%20%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0A%20%20%20%20if(dailyBalances.get(4)%3D%3D%20918)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22error%20%40%20dailyBalances%20index%204%22)%3B%0A%20%20%20%20%20%20%20%20if(verbose)%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22%5Ct%5Ct%205th%20element%20of%20dailyBalances%20should%20be%20918.00%22)%20%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0A%0A%0A%20%20%20%20if(%20Account.getParentCode()%3D%3D%2012810)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22Account.getParentCode()%20wrong%20%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%2F%2FtoString%20Tests%0A%20%20%20%20%20%20%20%20String%20str%20%3D%20jamesAcct.toString()%3B%0A%0A%20%20%20%20if(str.indexOf(%22SavingsAccount%22)%20%3D%3D%200%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22toString()%20should%20start%20w%2Fclassname.%20i.e.%20%5C%22SavingsAccount%5C%22%20%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20str%20%3D%20str.toLowerCase()%3B%0A%0A%20%20%20%20if(str.contains(%22number%22)%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22toString()%20incorrectly%20formatted%2C%20Account%20number%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20if(str.contains(jamesAcct.getAccountNumber()%20%2B%22%22)%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22toString()%20incorrectly%20formatted%2C%20Account%20number%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20if(str.contains(%22balance%22)%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22toString()%20incorrectly%20formatted%2C%20re%3A%20account%20balance%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20if(str.contains(jamesAcct.getCurrentBalance()%20%2B%22%22)%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22toString()%20incorrectly%20formatted%2C%20re%3A%20account%20balance%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%2F%2F%20ArrayList%3CPerson%3E%20getOwners()%20%20%20%20%0A%0A%20%20%20%20%0A%20%20%20%20if(str.contains(%22owner%22)%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22toString()%20incorrectly%20formatted%2C%20re%3A%20Account%20Owners%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20ArrayList%3CPerson%3E%20jamesAcctOwners%20%3D%20jamesAcct.getOwners()%3B%0A%20%20%20%20for(Person%20p%20%3A%20jamesAcctOwners)%7B%0A%20%20%20%20%20%20%20%20String%20strName%20%3D%20p.getName().toLowerCase()%3B%0A%20%20%20%20if(str.contains(strName)%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22toString()%20incorrectly%20formatted%2C%20re%3A%20Account%20Owners%22)%3B%0A%20%20%20%20%20%20%20%20if(verbose)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p2(%22%5Ct%5Ct%20%22%20%2B%20str%20%2B%20%22%5Cn%20%5Ct%5Ct%5Ct%20Missing%20%22%20%2B%20strName)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2F%2Fend%20of%20for-each%0A%0A%0A%20%20%20%20if(str.contains(%22interest%20rate%22)%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22toString()%20incorrectly%20formatted%2C%20re%3A%20interest%20rate%20%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20if(str.contains(jamesAcct.getInterestRate()%20%2B%20%22%22)%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p2(%22toString()%20incorrectly%20formatted%2C%20re%3A%20interest%20rate%20%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0A%0A%0A%20%20%20%20Person%20jorge%20%3D%20new%20Person(%22jorge%22%2C%2017)%20%3B%0A%20%20%20%20CertificateOfDeposit%20cd_foo%20%3D%20new%20CertificateOfDeposit(jorge%2C%20500)%3B%0A%20%20%20%20cd_foo.withdraw(100%2C%20true)%3B%0A%20%20%20%20double%20jorgesMoney%20%3D%20cd_foo.getCurrentBalance()%3B%0A%20%20%20%20if(jorgesMoney%20%3D%3D%20200%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20if(%20jorgesMoney%20%3D%3D%20400)%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22You%20did%20not%20apply%20the%20EARLY_WITHDRAW_PENALTY%20for%20a%20CD’s%20early%20withdrawal%22)%3B%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%20%20%20%20p2(%22Certificate%20of%20Deposit%20has%20wrong%20balance%20after%20early%20withdrawal%22)%3B%0A%0A%20%20%20%20%7D%0A%0A%0AAccount%20sb%20%3D%20new%20SavingsAccount(%20jorge%2C%20100%20)%3B%0AAccount%20sb2%20%3D%20new%20SavingsAccount(%20joe%2C%20100)%3B%0Aif(%20sb2.comparesTo(sb)%20%3D%3D%201)%0A%09correct%2B%2B%20%3B%0Aelse%0A%09%7B%0A%09wrong%2B%2B%3B%0A%09p2(%22Account’s%20comparesTo%20not%20implemented%20correctly%22)%3B%0A%09%7D%0A%0A%0ASavingsAccount%20sb33%20%3D%20new%20SavingsAccount(%20jorge%2C%20100%20)%3B%0A%0Asb33.updateInterestRate(3.3)%3B%0Aif(%20sb33.getInterestRate()%3D%3D%203.3)%0A%09correct%2B%2B%3B%0Aelse%0A%7B%0A%09wrong%2B%2B%3B%0A%09p2(%22Savings%20account%20error%20involving%20interestRate%22)%3B%0A%09p2(%22%5Ct%20either%20getInterestRate()%20or%20%2C%20more%20likely%2C%20updateInterestRate()%20is%20wrong%20%22)%3B%0A%0A%7D%0A%0A%0Adouble%20ball_yr1%20%3D%20sb33.projectBalance(1)%3B%0Aif(%20Math.abs(ball_yr1%20-%20103.350372874721)%3C%200.000001)%0A%09correct%2B%2B%20%3B%0Aelse%0A%09%7B%0A%09wrong%2B%2B%3B%0A%09p2(%22SavingAccount’s%20projectBalance()%20incorrect%22)%3B%0A%09%7D%0A%0A%0A%09p2(%22********************************************************************%22)%20%3B%0A%09p2(%22********************************************************************%22)%20%3B%0A%09p2(%22%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20SCORE%20%20%22)%20%3B%0A%09p2(%22********************************************************************%22)%20%3B%0A%09p2(%22********************************************************************%22)%20%3B%0A%09p2(%22********************************************************************%22)%20%3B%0A%0A%20%20%20%20p2(%22——————————-%22)%3B%0A%20%20%20%20p2(%22Correct%20%3A%20%20%22%20%2B%20correct)%3B%20%20%20%20%0A%20%20%20%20p2(%22Wrong%20%20%20%3A%20%20%22%20%2B%20wrong)%3B%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%7D%0A%0A%0Avoid%20p2(String%20s)%7B%0A%20%20%20%20System.out.println(s)%3B%0A%7D%0Avoid%20p2(int%20s)%7B%0A%20%20%20%20System.out.println(s)%3B%0A%7D%0Avoid%20p2(boolean%20s)%7B%0A%20%20%20%20System.out.println(s)%3B%0A%7D%0A%20%20%20%20%0A%0A%0A%7D%0A%20″ message=”Tester.java” highlight=”” provider=”manual”/]

When you are done, you can begin the Bank project .