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

29th Dec 2018, 8:54 AM
mordorminer
mordorminer - avatar
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);
29th Dec 2018, 9:19 AM
Sekiro
Sekiro - avatar
+ 2
Here I added some comment to get better understanding: https://code.sololearn.com/cuiGIORfCR8N/?ref=app
29th Dec 2018, 9:29 AM
Sekiro
Sekiro - avatar
+ 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 😉
29th Dec 2018, 9:30 AM
Sekiro
Sekiro - avatar
+ 1
thank you so much
29th Dec 2018, 9:28 AM
mordorminer
mordorminer - avatar