Quote (Kellye @ Mar 2 2014 05:58pm)
Thanks, I semi understand. I'm just starting on increments this week. I havn't touched arrays at all yet, but I have briefly seen them in the book.
Essentially you are just creating a lookup table where you can search for the name of the planet a user inputted to grab its value from the table. Unfortunately I don't know the name of these for java. After a quick google search looks like HashMap() is the function you are looking for if you want to implement something like this:
Code
private static final Hashtable<String,Integer> MYHASH = new Hashtable<String,Integer>() {{
put("foo", 1);
put("bar", 256);
put("data", 3);
put("moredata", 27);
put("hello", 32);
put("world", 65536);
}};
I'm sure someone else will come along and add more needed details or a better method for storing string, double indexes.
Using this method will eliminate allot of your if/elseif parsing you are doing.
More information about hashmaps can be found here:
http://docs.oracle.com/javase/7/docs/api/java/util/HashMap.htmlThis post was edited by AbDuCt on Mar 2 2014 04:03pm