Hi and thanks for takin a look at my problem:)
I have to build a share method which checks to see if two balances are equal then which ever is the larger balance it transfers 50% of the funds to the smaller account.
I have work it out so it deducts the 50%, and can recognise when the two balances are equal.
The problem is that it is not working out which is the larger balance and i have no idea how to set the reciever this.account.getBalance as an argument for transfer() in the type of MoneyFrog the class.:(:mad:
My transfer method and share method in MoneyFrog class
The transfer method in the account classCode:
/**
* transfers half of the balance of the receiver frog to the argument frog.
*/
public void transfer(MoneyFrog aFrog)
{
double anAmount = this.account.getBalance()/2;
this.account.transfer(aFrog.account, anAmount);
}
public void share(MoneyFrog aFrog)
{
this.lastReceived = false;
this.lastGiven = false;
if(aFrog.account.getBalance() != this.account.getBalance())
{
if(aFrog.account.getBalance() < this.account.getBalance())
{
this.transfer(aFrog);
aFrog.setLastReceived(true);
this.setLastGiven(true);
}
else
{
if(aFrog.account.getBalance() > this.account.getBalance())
{
this.transfer(aFrog);
this.lastReceived = true;
aFrog.lastGiven = true;
}
}
}
}
Any other parts needed pls ask.Code:public boolean transfer(Account toAccount, double anAmount)
{
if (this.debit(anAmount))
{
toAccount.credit(anAmount);
return true;
}
else
{
return false;
}
}
Pls any help would be great even a point in the right direction.

