Bear Bibeault wrote:Aside from all the statics (what is up with that?), here are a few off-the-cuff things I'd advise:
Get out of the habit of freeze-drying variables names. ln is bad; lastName is good. fn is bad; firstName is good. And a is just horrible.
Why is the age being passed in as a String that needs to be parsed? Declare the parameter as the type it should be.
What's the access type of your non-static instance variables? They should be private unless you have a really good reason otherwise.
Avoid superfluous comments. Just like the boy who cried wolf, superfluous comments cheapen the value of useful comments. "Make all last names uppercase" is not necessary -- it's quite clear form the code what's going on. Save the comments for things that really need it.
Don't put return values in parentheses unnecessarily. It just adds noise to the code.
Dustin Van der Woodsen wrote:Age is hence being passed in as a String because it's all part of a bigger string, gotten from a FileReader.
Have you really been told to use a tokenizer? If you look here, it tells you not to use a tokenizer in new code. It also make a suggestion of what to use instead. I think you might have to query that with your teachers.Dustin Van der Woodsen wrote: . . . some program which . . . and utilizes StringTokenizer, . . .
Campbell Ritchie wrote:
Have you really been told to use a tokenizer? If you look here, it tells you not to use a tokenizer in new code. It also make a suggestion of what to use instead. I think you might have to query that with your teachers.Dustin Van der Woodsen wrote: . . . some program which . . . and utilizes StringTokenizer, . . .
An alternative is to use a Scanner; there are more details in the Java Tutorials.
And welcome to the Ranch
Campbell Ritchie wrote:A method like averageAge() does not belong in the Person class because one Person object does not “know” any other Person object’s age. You can put the average age method in a different class, however, maybe wherever your List lives.
Yes. I realised Jesper had made the suggestion, but didn’t realise OP had already carried it out.Tony Docherty wrote: . . . Isn't this what the OP has done already . . .
Dustin Van der Woodsen wrote:I'm not sure how I would, for example, go about doing this:
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Consider Paul's rocket mass heater. |