This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Transferring money between two accounts using a driver and blueprint class  RSS feed

 
Samuel King
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically this is the assignment:
Modify the Account class to provide a service that allows funds to be transferred from one account to another.
Note that a transfer can be thought of as withdrawing money from one account and depositing to another (for full credit, have your transfer method invoke the withdraw and deposit methods appropriately).
Modify the main method of the Transactions class to demonstrate this new service.
Here's a prototype / header for the new transfer method of the Account class:
public void transfer (Account acctToWithdrawFrom, double amountToTransfer, double fee)
// NB: The fee is charged to the account from which the amount is withdrawn.


i've add


to the driver class/ transactions


and

public void transfer (Account acctToWithdrawFrom, double amountToTransfer, double fee)
{
this.withdraw (amountToTransfer, fee);
this.deposit (amountToTransfer);

}

to the blueprint class (accounts)

clearly it's wrong but an someone help me? Thanks in advance



Account class



 
Jason Bullers
Ranch Hand
Posts: 115
11
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Samuel King wrote:

...

clearly it's wrong but an someone help me? Thanks in advance

Look at the parameters of that method. You aren't using all of them. You probably should be if you want to transfer money between accounts.

Why do you think it's wrong? You haven't given any errors and I don't see any expected values anywhere in the code you posted, so what has you stumped?

 
Samuel King
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm really not sure
Which parenthesis am I not using?
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He didn't say parenthesis. He said parameter.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!