This is hopefully a pretty simple one. I've got an abstract superclass (Account) that defines the generic behavior of a bank account. One of the methods (non abstract) is to transfer funds from one account to another. My set up so far is this:
The problem is that the balance variable (which should refer to the variable balance of the instance the money is being transferred from) is being initialized at 0.0d - which is the value I assigned to it in the superclass.Code:public void transfer(double transferAmount, Account transferToAccount) { if(balance-transferAmount<0.00) { System.out.println("Insufficient Funds - transfer denied"); } else if (balance-transferAmount>=0.00) { balance-=transferAmount; transferToAccount.balance += transferAmount; System.out.println("Transfer Complete"); transferToAccount.printBalance(); } }
On top of that, the transferToAccount methods aren't working - they are all initialized at the value of the superclass variable as well. I don't know how to get to these instances. Does that make sense?
Thanks in advance![]()


Reply With Quote



Bookmarks