Applets problems

Hi can anyone help me pleaseThanks
[55 byte] By [Sehama] at [2007-11-26 22:25:47]
# 1
Yes.Or maybe no.
itchyscratchya at 2007-7-10 11:26:55 > top of Java-index,Desktop,Core GUI APIs...
# 2

Ok,

I trying to do a simulated ATM machine as a final year project and i got some of its functions done and the others not.

i am trying to tranfer money between currentAccount and savingsAccount using a method called Transfer but its not working can you help me please to sort that out.

here is the code for the BankAcount that includes the method

import java.util.*;

import java.text.*;

import java.io.*;

public class BankAccount{

BankAccount currentAccount;

BankAccount savingsAccount;

Customer cus;

public int accountNo;

public double balance;

public BankAccount(){

}

public BankAccount(int accountNo, double balance){

this.accountNo = accountNo;

this.balance= balance;

}

public int getAccountNo(){

return accountNo;

}

public double getBalance(){

return balance;

}

public void deposit(double amount){

this.balance = balance;

balance = balance + amount;

}

public void withdraw(double amount){

this.balance = balance;

balance = balance - amount ;

}

public double transfer(BankAccount currentAccount, BankAccount savingsAccount,double amount) {

//fetch the currentAccount

balance = currentAccount.getBalance();

if(balance == 0){

System.out.print("Can not transfer money ");

}

balance = savingsAccount.getBalance();

if(balance == 0) {

System.out.print("Invalid amount");

}

if(currentAccount.getBalance() > amount){

balance = currentAccount.getBalance() - amount;

balance = savingsAccount.getBalance() + amount;

}

return balance;

}

public void PrintReciept(){

Date today = new Date();

SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");

String date = formatter.format(today);

String message = "Account No:" + getAccountNo()+

"\n Customer No:" + cus.getCustomerNumber()+

"\n\n" + date+

"\n\n Balance:" + getBalance()+

"\n\n Thank You\n"+

"-\n";

}

}

Sehama at 2007-7-10 11:26:55 > top of Java-index,Desktop,Core GUI APIs...
# 3

What are you trying to do in that method?

First you pass in two bank accounts - why would you call "accountA.transfer(accountB, accountC, amount)"? Where's the money flowing? You say you're trying to transfer from the current to the savings, ie accountB to accountC, so why call a method on accountA? If you want a method to transfer funds I would suggest,public void transferTo(BackAccount toAccount, double amount) throws InsufficientFundsException {...}

But as for the problem, you should declare a local variable for the return value since you're modifying the balance of accountA via the field - and accountA is the one which seemingly has no involvement in the transaction (which as I say is daft because you're calling the method on it).

itchyscratchya at 2007-7-10 11:26:55 > top of Java-index,Desktop,Core GUI APIs...
# 4
thanks for your reply,but cn you please give me the full code of it as i have tried many amny times but no way to fix it.thanks a million
Sehama at 2007-7-10 11:26:55 > top of Java-index,Desktop,Core GUI APIs...
# 5
No, it's your final year project and frankly I couldn't give a toss whether you pass or fail - you figure it out, you lazy git.
itchyscratchya at 2007-7-10 11:26:55 > top of Java-index,Desktop,Core GUI APIs...
# 6
Thanks
Sehama at 2007-7-10 11:26:55 > top of Java-index,Desktop,Core GUI APIs...
# 7
You're welcome :o)
itchyscratchya at 2007-7-10 11:26:55 > top of Java-index,Desktop,Core GUI APIs...