私はUNOカードゲームを開発しようとしていますが、今ではデッキ全体を保持できるデータ構造が必要なところに到達し、それをいくつかの場所(プレイヤー、廃棄パイル、ドローパイル)。コードは次のようなものになります。後で要素をステークホルダーに配布できる要素を保持するための最良のデータ構造ですか?
public class UnoGame
{
public UnoGame()
{
SomeDataStructure<Card> unoDeck = generateUnoCards();
List<Cards> player1 = unoDeck.get(7);
List<Cards> player2 = unoDeck.get(7);
List<Cards> discardPile = unoDeck.get(1);
List<Cards> drawPile = unoDeck.getRest();
}
private static SomeDataStructure<Card> generateUnoCards()
{
SomeDataStructure<Card> cards = new SomeDataStructure<Card>(108);
// Here we can create the proper cards and add them to the data structre
Collections.shuffle(cards);
return cards;
}
}
私の要件に合った組み込みのデータ構造がありますか?または、自分のデータ構造を実装する必要がありますか?
ArrayList>?さらに優れています:HashMap >。キーは名前、arraylistはカードです。 –