It's not a secret anymore!*
The moose likes Java in General and the fly likes trouble with program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "trouble with program" Watch "trouble with program" New topic
Author

trouble with program

erin topper
Greenhorn

Joined: Mar 13, 2012
Posts: 2



The problems I am having are: I am trying to get the SSN to have a hyphen. I am getting an error on the + sign just on the one line under the return SSN method.
I am also having trouble getting the annual salary to be a decimal. I keep getting an error using the decimal format.

Any help would be great!
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1509
    
    5

Hi erin topper,

Please TellTheDetails. If you take a look at those compile time errors, you will get pretty much information about how to fix those.

I've not gone through decimal code, because I found SSN code itself pretty weird. There, first thing is - you are calling a getter method, which returns a String, but you are not assigning it to anything. This is the reason for compilation error.

But the most odd part I found was - you are making a recursive call for getter method of SSN! Why is it so? You can directly access the member right? Besides, there is no exit condition, so that method is gonna blow the call stack.

Further to that, you are not doing any validation within getter/setter methods. Even if you get rid of compilation errors and remove recursive calls, you are still assuming that SSN would be always 10 digit. What if someone provides SSN of length 1 during object creation?

I hope this helps.

And Welcome to CodeRanch!


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: trouble with program