Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Transferring money between two accounts using a driver and blueprint class

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Ranch Hand
Posts: 115
11
IntelliJ IDE Clojure Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm really not sure
Which parenthesis am I not using?
 
Marshal
Posts: 75637
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
He didn't say parenthesis. He said parameter.
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic