I am a beginner. This is an assignment given my class teacher. I have designed a class named Bank. Here I want to OPEN ACCOUNT, DEPOSIT MONEY, WITHDRAW MONEY and PRINT STATEMENT. My problem is in the PRINT STATEMENT method. I want to show, TIME, DATE, and last OPERATION(withdraw or deposit) and OPERATION AMOUNT. Now, I don't understand how I can get the last operation (whether it is withdraw or deposit?) and amount. Please see my code and do please help me. I have to submit it anyway, it will give me 10 marks. Do please help me.
Thanks in advance.
]//************************************************************************************************************************ // Lab Performance: 23 March 2011, Sec: C, Name: Ahamed Md. Faysal, ID: 09-14363-2, Email: [email]faysal40@gmail.com[/email], 01912120400 //************************************************************************************************************************ //***************************************** Class: Bank *************************************************** class Bank { public String name; public static int accountNumber = 1000; public int balance; Bank() { name = "A"; accountNumber = accountNumber + 1; balance = 50000; } Bank(int moreThan50) { if(moreThan50>50000) // { name = "B"; accountNumber = accountNumber + 1; balance = moreThan50; } else { System.out.println("Error !!! Initial depository amount must be more than 50000."); } } //************************************ withdraw: Withdraw money from the account ************************** public void withdraw(int wAmount) { balance = balance - wAmount; System.out.println(wAmount + " Taka has been successfully withdrawn."); } //************************************ dposit: Depositing money in the account ****************************** public void deposit(int dAmount) { balance = balance + dAmount; System.out.println(dAmount + " Taka has been successfully deposited"); } //********************************** checkBalance: Checking the current balance ***************************** public void checkBalance() { System.out.println("Your current balance is: " + balance); } //****************************************** Main Method *************************************** public static void main(String args []) { System.out.println("\t\t\tWelcome to Touch Mangla Bank Limited\n\t\t================================="); /* //Bank a1 = new Bank(); //Bank a1 = new Bank(40000); Bank a1 = new Bank(60000); a1.withdraw(50000); a1.checkBalance(); a1.deposit(120000); a1.checkBalance(); */ BankStatement b1 = new BankStatement(40000); BankStatement b2 = new BankStatement(65000); b2.checkBalance(); b2.deposit(450000); b2.printStatement("25 March 2011", "2:00 am"); System.out.println(); } } //************************************* Class: BankStatement ****************************************** class BankStatement extends Bank { public String date; public String time; public String operation; public int amount; BankStatement() { super(); } BankStatement(int mT50) { super(mT50); } //***************************** printStatement: Printing the bank statement ****************************** public void printStatement(String d, String t) { date = d; time = t; System.out.println("\t\t\tBank Statement\n_____________________________________"); System.out.println("Date: " + date + "\t\tTime: " + time); System.out.println("Operation: " + operation + "\t\t\tAmount: " + amount); } }