• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Still struggling with constructors

 
Troy Johnson
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 ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • 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?
 
Michael Dunn
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
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • 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
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic