This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
... this looks an awful lot like a homework assignment ...
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Melinda Wilson: Can any part of this code sample be furthered condensed?
Yes. Basically you are having a mapping between Strings and ints.
Than you can easily use the Map to lookup ages for a specific String. Take a look at java.util.Map and its implementations.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Melinda Wilson
Ranch Hand
Joined: Jul 05, 2001
Posts: 35
posted
0
Originally posted by Jessica Sant: ... this looks an awful lot like a homework assignment ...
No it is not a homework assignment. [ May 07, 2002: Message edited by: Melinda Wilson ]
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
Part II has a lot of redundancy. It seems to reduce to
This could probably be accomplished as:
For part I, I'd probably list all the states in a file, and read the file into a Map of some sort which allowed me to look up the min age for a given state, without a bunch of if/else if clauses. The Properties class would be a simple way to do this. It's probably not worth the trouble for the code as it is now - but if you plan to add the remaining states, or if you need to have other state-dependant information, I'd try to put it in a separate file where it's easy to read and update if necessary.