@Test public void testDeckOfCards() { Assert.assertEquals(deck.get(0).getSuit(), deck.get(12).getSuit()); Assert.assertEquals(deck.get(13).getSuit(), deck.get(25).getSuit()); Assert.assertEquals(deck.get(26).getSuit(), deck.get(38).getSuit()); Assert.assertEquals(deck.get(39).getSuit(), deck.get(51).getSuit()); Assert.assertEquals(deck.get(0).getRank(), deck.get(13).getRank()); Assert.assertEquals(deck.get(0).getRank(), deck.get(26).getRank()); Assert.assertEquals(deck.get(0).getRank(), deck.get(39).getRank()); }
public DeckOfCards() { Suit[] suits = Suit.values(); Rank[] ranks = Rank.values(); int numCard = 0; for (Suit aSuit : suits) { for (Rank aRank : ranks) { Card newCard = new Card(aSuit, aRank); cards[numCard++] = newCard; } } }
DeckOfCards extends AbstractList<Card> { public DeckOfCards() { Suit[] suits = Suit.values(); Rank[] ranks = Rank.values(); int numCard = 0; for (Suit aSuit : suits) { for (Rank aRank : ranks) { Card newCard = new Card(aSuit, aRank); cards[numCard++] = newCard; } } } }
DeckOfCards extends AbstractList<Card> { public DeckOfCards() { Suit[] suits = Suit.values(); Rank[] ranks = Rank.values(); int numCard = 0; for (Suit aSuit : suits) { for (Rank aRank : ranks) { Card newCard = new Card(aSuit, aRank); cards[numCard++] = newCard; } } } DeckOfCards(); }
DeckOfCards extends AbstractList<Card> { public DeckOfCards() { Suit[] suits = Suit.values(); Rank[] ranks = Rank.values(); int numCard = 0; for (Suit aSuit : suits) { for (Rank aRank : ranks) { Card newCard = new Card(aSuit, aRank); cards[numCard++] = newCard; } } } DeckOfCards(); @Override Card get(int index); Card set(int index, Card card); @Override int size(); }
DeckOfCards extends AbstractList<Card> { public DeckOfCards() { Suit[] suits = Suit.values(); Rank[] ranks = Rank.values(); int numCard = 0; for (Suit aSuit : suits) { for (Rank aRank : ranks) { Card newCard = new Card(aSuit, aRank); cards[numCard++] = newCard; } } } DeckOfCards(); @Override Card get(int index); Card set(int index, Card card); @Override int size(); static final int NUM_CARDS; }