0
How can i add a money transfer method?
hey, I'm trying to do a transfer method. It does money transfer beetwen 2 account (for now). Could you help me pls:) https://code.sololearn.com/cAG598DEUtli/?ref=app
4 odpowiedzi
+ 2
You can do the trasfer method like this:
public void Transfer(double v1, BankAccount recieverAccount)
{
AccBalance -= v1;
recieverAccount.AccBalance += v1;
}
The method takes as parameter an object of the BankAccount class that is the reciever bank account then you have to call the method from the sender object, for example:
account.Transfer(200, account1);
+ 2
Here I added some comment to get better understanding:
https://code.sololearn.com/cuiGIORfCR8N/?ref=app
+ 2
You are welcome mordorminer !
By the way in your code after the transfer method you have a curly brace } in surplus you should delete it or will give you error 😉
+ 1
thank you so much