This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Still struggling with constructors

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I still seem to be struggling a bit getting this to work properly. I have made some modifications based upon previous suggestions and responses. I am tyring to modify the code by adding two additional constructors, one that takes the "annual interest rate" and "loan amount", and one that takes just the "loan amount". I need to use the keyword "this" to invoke new constructor. I am also to write a test program to test all constructors. Here is my original code and the modifications I have made. Please let me know if anyone has any suggestions or can help. Sorry, for the repetitive posts. I am new to Java. Thanks.

Here is my original code:

Here is the modification and solution I have so far

[ October 22, 2003: Message edited by: Troy Johnson ]
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To call one constructor from another, you use "this()". In the parentheses, you put the arguments to pass to the other constructor. For example

Is that enough information?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I *think* I can see what you're trying to do now

(rest of code snipped)
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I *think* I can see what you're trying to do now


Well, indeed. We all could see that. I would hoping to give him enough information to work this out for himself. He won't learn anything at all from cutting and pasting your code into his assignment!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest, my post was more of a correction to my post in his other thread.
As for him learning Vs not learning, that's for him to choose, not me.
 
Troy Johnson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone for all of your help. I greatly appreciate it. I think I finally got it figured out now. Thanks again.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael --
Sorry for the rebuke. I was annoyed with someone else and I took it out on you.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest, not a problem, and while I'm here, I would like to say thanks for a whole bunch of your code snippets that have turned many of my Java 'doubtful' areas into 'hey, light bulb's now on'.
Thanks again.
 
He's my best friend. Not yours. Mine. You can have this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!