• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Still struggling with constructors

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic