pass a variable from one object to another
each customer is an object. there are 3 classes. the main class, a current account class and an abstract account. i want one customer to be able to transfer money to another but have no idea how. when i withdraw from one customer can i then automatically deposit to another customer that amount. in other words can i reference the other object from within the current account class. The transfer method is at the very end. Any help would be great thatnks.
The 3 classes are below:
main
Code:
class BankAccountTester
{
public static void main(String[] args)
{
CurrentAccount acc1 = new CurrentAccount("Ann Smith", 300);
CurrentAccount acc2 = new CurrentAccount("Ben Murphy");
acc1.deposit(7550);
acc2.deposit(200);
acc1.transfer
}
}
current account
Code:
public class CurrentAccount extends Account
{
private int accountNo;
private static int accNo;
public CurrentAccount(String name)
{
super(name);
}
public CurrentAccount(String name, double number)
{
super(name, number);
}
public int accNo()
{
return accNo;
}
public void deposit(double deposit)
{
double b;
b = deposit + super.getCurrentBal();
super.setCurrentBal(b);
System.out.println("********" + getCurrentBal());
}
public void withdraw(double withdraw)
{
double b;
b = super.getCurrentBal() - withdraw;
super.setCurrentBal(b);
System.out.println("********" + getCurrentBal());
}
public void transfer(double number)
{
}
}