Its the class BankAccount that im having trouble with. In it i have to add an appropriate constructor and methods. I need methods for withdrawing and depositing, an addTransaction method to add a new instance to the array, read in its details (including date, etc.) and update the balance using the deposit or withdraw methods; a printStatement method to give a printout as indicated above.
I also need to add an application class which will be used to test the other classes.
If anyone can get me any advice on my bankaccount class or point out any mistakes that im making or anything which i should change, it would be very much appreciated.
There are a few things I don't really understand in your BankAccount class. It seems to me that several things got mixed up.
If I had to make a BankAccount class I would prefer the following interface:
Class BankAccount{
public BankAccount()
publicvoid withdraw(double amount)
publicvoid deposit(double amount)
public Transaction getTransaction(int index)
publicint transactionCount()
publicdouble getCurrentBalance()
privatevoid addTransaction(Transaction t)
}
in my withdraw and deposit method I change the currentBalance and I create a new Transaction and add it to the collection of Transactions (since I hate arrays, I would probably use one of the Collection-classes from the java.util package to store my transactions). The PrintTransaction and ReadTransaction methods I would not place in the BankAccount-class, neither in my Transaction- class. It makes my classes depend on the UI. Prove of this is, since I don't have your uuInOut class, I need to change al lot of code in order to get things right. It's better to do this printing-logic in a class of its own or in your Application-class.
An alternative interface could be:
Class BankAccount{
public BankAccount()
public Transaction getTransaction(int index)
publicint transactionCount()
publicdouble getCurrentBalance()
publicvoid addTransaction(Transaction t)
}
In this case you add a transaction to the BankAccount. In this method you change the currentBalance depending on the type of Transaction and then add it to the collection of transactions.
All this remarks apply also to the other classes in your project. They depend too heavy on the UI.