Project 1) Accounts
Objective To employ inheritance, abstract classes, and polymorphism to create account types. Your final project should have a runner class that demonstrates (by printing out etc...) the functionality of each type of class.
When you are done, execute the Bank.java runner class. Althought his class does not test all of your methods, it should compile run and give you some feedback regarding some of the methods.
Required Classes,methods, instance variables
- Create the following classes
- An abstract super class called Account
- Static variables
- static int nextAccountNum;
- Constructor
- public Account(double balance)
- the parameter
balanceis used to initalize currentBalance - use
nextAccountNumensure that allaccountNumber's are unique
- the parameter
- private int accountNumber ;
- private double currentBalance;
- public Account(double balance)
- methods
- public int getAccountNumber()
- public boolean equals( Account other ) //returns true if this and other have same
accountNumber - public void deposit(double amount)
- public double getCurrentBalance()
- public boolean withdraw(double amount); always returns true
(subclasses will override this behavior and will not always return true)
- Static variables
- An abstract super class called Account
- CheckingAccount extends Account
- instance variables
- private int checksWritten ;
- methods
- public void writeCheck(double amount) //this method should increment checksWritten and deduct amount from the balance
- SavingsAccount extends Account
- static variables
- 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
- static variables
- CertificateOfDeposit class that extends SavingsAccount
Create a runner class that demonstrates the functionalities of each class. There is no one correct way to complete the assignment. At a bare minimum,make sure that you implement and add functionality to each method.