I’m beginner in java and I’m currently creating a card game like gin rummy for Android. I want to know what’s the best implementation for creating Hand class? What’s the best way where to store the card returned by Deck.dealt()?
- Array
- ArrayList
- Vector
- HashSet
- LinkedList
Also, I would appreciate if anyone could provide a gin rummy open source links.
Store them in an
ArrayList.Cards in a hand are in a certain order, not in an unordered pile. This ordering is preserved in a
Listover aSet.ArrayListalso gives you the opportunity to select a specific card by index, which will be helpful as you implement the game.Keep in mind that as long as you design your
Handclass properly, you can always change this data structure easily at any point in the future. As long as you keep this in mind with any class you design, you can always change it if you realize you need something different.