Hey guys, new here.
I'm studying for my java final and we were given 3 questions about where an Array or HashTable would apply. If you guys could give me your thoughts on what would apply I would appreciate it.
1) Ship has-man Deck, where the number and arrangement of decks can not change after the ship is built.
I think it would an Array, since the number of decks can't be changed. (right?/any other comments on this one)
2) Ship has-man Passenger, where the ship's booking manager needs to be able to add new passengers, and print out the current passenger list in alphabetical order, whenever she wants to.
I think it would be a HashTable because new passengers need to be added, but as for the sorting, does that matter either way? (right?/any other comments on this one)
3) Ship has-many Stateroom, where the ship's steward needs to be able to enter a stateroom identifier at a terminal, and get back the names and ages of the people currently occupying that room.
I think it would be a HashTable because the steward needs to access a specific room. Also, it would be a HashTable because the identifier would be the key, and the names and ages could be from a person object that the key refers to? (right?/any other comments on this one)
Thanks a lot guys for any help at all.:cool:
3 questions: Would I use an Array or HashTable for them?
Started by Treymac, Dec 13 2007 10:36 PM
3 replies to this topic
#1
Posted 13 December 2007 - 10:36 PM
|
|
|
#2
Posted 14 December 2007 - 05:02 AM
1, Array
2, Hash Table / Vector Object
3, Array (Multidimentional / Associative aka. Map)
2, Hash Table / Vector Object
3, Array (Multidimentional / Associative aka. Map)
~Aristotle said:
It is the mark of an educated mind to entertain a tought without accepting it
#3
Posted 23 December 2007 - 09:56 PM
Awesome, thanks for the help. I ended up with 100% on my final :D
#4
Posted 24 December 2007 - 07:34 AM
:D Glad to help.
~Aristotle said:
It is the mark of an educated mind to entertain a tought without accepting it


Sign In
Create Account

Back to top









