class BankAccount
{
private String AccountNumber;
private double Balance;
public BankAccount(String AccountNumber, double Balance) {
this.AccountNumber = AccountNumber;
this.Balance = Balance;
}
public void AddFunds(double value)
{
Balance += value;
}
public void RemoveFunds(double value)
{
Balance -= value;
}
@Override
public String toString() {
return "BankAccount{ " + "AccountNumber=" + AccountNumber + ", Balance=" + Balance + " }";
}
}
class TransferManager
{
public TransferManager(BankAccount Source, BankAccount Destination, double Value) {
this.Source = Source;
this.Destination = Destination;
this.Value = Value;
}
private BankAccount Source;
private BankAccount Destination;
private double Value;
public void Transfer()
{
Source.RemoveFunds(Value);
Destination.AddFunds(Value);
}
}
public class Bank {
public static void main(String[] args){
BankAccount from = new BankAccount("4321", 1200);
BankAccount to = new BankAccount("1234", 200);
System.out.println(from);
System.out.println(to);
TransferManager mymgr = new TransferManager(from,to,300);
mymgr.Transfer();
System.out.println(from);
System.out.println(to);
}
}
interface IBankAccount
{
public void AddFunds(double value);
public void RemoveFunds(double value);
}
...
class BankAccount implements IBankAccount
...
class TransferManager
{
public TransferManager(IBankAccount Source, IBankAccount Destination, double Value) {
...