APCS Account class Name: _________________

advertisement
APCS Account class
Name: _________________
Create an Account class with the following fields:
 ID
 Balance
 Date created (look up the Date object)
 Static annual interest rate
The Account class should have the following methods:
 2 argument Constructor for a specified ID and balance
 accessors / modifiers that make sense – use Eclipse.
 toString()
 getMonthlyInterest()
 deposit(double amount)
 withdraw(double amount)
 getInterestRate() – static method
 setInterestRate() – static method
Should the class have any additional accessors or modifiers?
Test your class by creating an Application/Client.
Set the annual interest rate to 6%, verify the getMonthlyInterest() method returns
0.5% times the current balance. Note, the annual interest rate is a static variable.
Think of the exception conditions:
Can you withdraw more money than you have?
Can you withdraw a negative amount?
Can you deposit a negative amount?
Download