diff --git a/Card.java b/Card.java new file mode 100644 index 0000000..65e403e --- /dev/null +++ b/Card.java @@ -0,0 +1,108 @@ +public class Card { + private int quantity; + private int color; + private int shading; + private int shape; + + public Card(int theQuantity, int theColor, int theShading, int theShape){ + quantity = formatValue(theQuantity); + color = formatValue(theColor); + shading = formatValue(theShading); + shape = formatValue(theShape); + } + + private int formatValue(int val){ + if(val < 4 && val > 0){ + return val; + } else if (val >= 0){ + return val % 3 + 1; + } else { + return (((val % 3) + 3) % 3) + 1; + } + + } + public int getQuantity(){ + return quantity; + } + + public int getColor(){ + return color; + } + + public int getShading(){ + return shading; + } + + public int getShape(){ + return shape; + } + + public boolean isSet(Card second, Card third){ + boolean qtyIsRight = isRightForSet(quantity, second.getQuantity(), third.getQuantity()); + boolean colorIsRight = isRightForSet(color, second.getColor(), third.getColor()); + boolean shadingIsRight = isRightForSet(shading, second.getShading(), third.getShading()); + boolean shapeIsRight = isRightForSet(shape, second.getShape(), third.getShape()); + + if(qtyIsRight && colorIsRight && shadingIsRight && shapeIsRight){ + return true; + } else { + return false; + } + + } + public boolean isRightForSet(int val1, int val2, int val3){ + if((val1 + val2 + val3) % 3 == 0){ + return true; + } else { + return false; + } + } + + public String toString(){ + String str = ""; + if(quantity == 1){ + str += "1"; + } else if(quantity == 2){ + str += "2"; + } else if(quantity == 3){ + str += "3"; + } + + + if(color == 1){ + str += "R"; + } else if(color == 2){ + str += "G"; + } else if(color == 3){ + str += "P"; + } + + if(shading == 1){ + str += "O"; + } else if(shading == 2){ + str += "T"; + } else if(shading == 3){ + str += "S"; + } + + if(shape == 1){ + str += "O"; + } else if (shape == 2){ + str += "D"; + } else if (shape == 3){ + str += "S"; + } + return str; + } + public boolean equals(Object obj) { + Card that = (Card)obj; + + return quantity == that.getQuantity() && + color == that.getColor() && + shading == that.getShading() && + shape == that.getShape(); + } + + +} + diff --git a/CardTest.java b/CardTest.java new file mode 100644 index 0000000..5139250 --- /dev/null +++ b/CardTest.java @@ -0,0 +1,69 @@ +import junit.framework.TestCase; + +public class CardTest extends TestCase { + + public void testConstructorAndGetters(){ + int expectedQuantity = 2; + int expectedColor = 1; + int expectedShape = 3; + int expectedShading = 2; + + Card card = new Card(expectedQuantity, expectedColor, expectedShading, expectedShape); + + assertEquals(expectedQuantity, card.getQuantity()); + assertEquals(expectedColor, card.getColor()); + assertEquals(expectedShading, card.getShading()); + assertEquals(expectedShape, card.getShape()); + } + + public void testConstructorModulo(){ + int expectedQuantity = 2; + int expectedColor = 1; + int expectedShape = 3; + int expectedShading = 3; + + Card card = new Card(4, 6, 11, -10); + + assertEquals(expectedQuantity, card.getQuantity()); + assertEquals(expectedColor, card.getColor()); + assertEquals(expectedShading, card.getShading()); + assertEquals(expectedShape, card.getShape()); + } + + public void testToString(){ + Card card = new Card(1,1,2,3); + assertEquals("1RTS", card.toString()); + Card card2 = new Card(2,3,3,1); + assertEquals("2PSO", card2.toString()); + Card card3 = new Card(3,2,2,2); + assertEquals("3GTD", card3.toString()); + } + + public void testIsSet(){ + Card card0 = new Card(1,1,3,1); + Card card1 = new Card(1,2,2,1); + Card card2 = new Card(1,3,1,1); + Card card3 = new Card(2,1,3,3); + Card card4 = new Card(3,1,3,2); + + assertTrue(card0.isSet(card2, card1)); + assertTrue(card0.isSet(card3, card4)); + assertFalse(card0.isSet(card1, card3)); + assertFalse(card0.isSet(card2, card4)); + + } + + public void testIsSetTransitive(){ + Card card0 = new Card(1,1,3,1); + Card card1 = new Card(1,2,2,1); + Card card2 = new Card(1,3,1,1); + Card card3 = new Card(2,1,3,3); + + assertTrue(card0.isSet(card2, card1)); + assertTrue(card1.isSet(card0, card2)); + assertTrue(card2.isSet(card1, card0)); + assertFalse(card0.isSet(card2, card3)); + assertFalse(card2.isSet(card0, card3)); + assertFalse(card3.isSet(card2, card0)); + } +} \ No newline at end of file diff --git a/src/Card.java b/src/Card.java old mode 100755 new mode 100644 index 9eed9a5..65e403e --- a/src/Card.java +++ b/src/Card.java @@ -1,6 +1,99 @@ public class Card { - // Create the rest of this class yourself + private int quantity; + private int color; + private int shading; + private int shape; + public Card(int theQuantity, int theColor, int theShading, int theShape){ + quantity = formatValue(theQuantity); + color = formatValue(theColor); + shading = formatValue(theShading); + shape = formatValue(theShape); + } + + private int formatValue(int val){ + if(val < 4 && val > 0){ + return val; + } else if (val >= 0){ + return val % 3 + 1; + } else { + return (((val % 3) + 3) % 3) + 1; + } + + } + public int getQuantity(){ + return quantity; + } + + public int getColor(){ + return color; + } + + public int getShading(){ + return shading; + } + + public int getShape(){ + return shape; + } + + public boolean isSet(Card second, Card third){ + boolean qtyIsRight = isRightForSet(quantity, second.getQuantity(), third.getQuantity()); + boolean colorIsRight = isRightForSet(color, second.getColor(), third.getColor()); + boolean shadingIsRight = isRightForSet(shading, second.getShading(), third.getShading()); + boolean shapeIsRight = isRightForSet(shape, second.getShape(), third.getShape()); + + if(qtyIsRight && colorIsRight && shadingIsRight && shapeIsRight){ + return true; + } else { + return false; + } + + } + public boolean isRightForSet(int val1, int val2, int val3){ + if((val1 + val2 + val3) % 3 == 0){ + return true; + } else { + return false; + } + } + + public String toString(){ + String str = ""; + if(quantity == 1){ + str += "1"; + } else if(quantity == 2){ + str += "2"; + } else if(quantity == 3){ + str += "3"; + } + + + if(color == 1){ + str += "R"; + } else if(color == 2){ + str += "G"; + } else if(color == 3){ + str += "P"; + } + + if(shading == 1){ + str += "O"; + } else if(shading == 2){ + str += "T"; + } else if(shading == 3){ + str += "S"; + } + + if(shape == 1){ + str += "O"; + } else if (shape == 2){ + str += "D"; + } else if (shape == 3){ + str += "S"; + } + return str; + } public boolean equals(Object obj) { Card that = (Card)obj; @@ -9,4 +102,7 @@ public boolean equals(Object obj) { shading == that.getShading() && shape == that.getShape(); } + + } + diff --git a/src/CardTest.java b/src/CardTest.java new file mode 100644 index 0000000..5139250 --- /dev/null +++ b/src/CardTest.java @@ -0,0 +1,69 @@ +import junit.framework.TestCase; + +public class CardTest extends TestCase { + + public void testConstructorAndGetters(){ + int expectedQuantity = 2; + int expectedColor = 1; + int expectedShape = 3; + int expectedShading = 2; + + Card card = new Card(expectedQuantity, expectedColor, expectedShading, expectedShape); + + assertEquals(expectedQuantity, card.getQuantity()); + assertEquals(expectedColor, card.getColor()); + assertEquals(expectedShading, card.getShading()); + assertEquals(expectedShape, card.getShape()); + } + + public void testConstructorModulo(){ + int expectedQuantity = 2; + int expectedColor = 1; + int expectedShape = 3; + int expectedShading = 3; + + Card card = new Card(4, 6, 11, -10); + + assertEquals(expectedQuantity, card.getQuantity()); + assertEquals(expectedColor, card.getColor()); + assertEquals(expectedShading, card.getShading()); + assertEquals(expectedShape, card.getShape()); + } + + public void testToString(){ + Card card = new Card(1,1,2,3); + assertEquals("1RTS", card.toString()); + Card card2 = new Card(2,3,3,1); + assertEquals("2PSO", card2.toString()); + Card card3 = new Card(3,2,2,2); + assertEquals("3GTD", card3.toString()); + } + + public void testIsSet(){ + Card card0 = new Card(1,1,3,1); + Card card1 = new Card(1,2,2,1); + Card card2 = new Card(1,3,1,1); + Card card3 = new Card(2,1,3,3); + Card card4 = new Card(3,1,3,2); + + assertTrue(card0.isSet(card2, card1)); + assertTrue(card0.isSet(card3, card4)); + assertFalse(card0.isSet(card1, card3)); + assertFalse(card0.isSet(card2, card4)); + + } + + public void testIsSetTransitive(){ + Card card0 = new Card(1,1,3,1); + Card card1 = new Card(1,2,2,1); + Card card2 = new Card(1,3,1,1); + Card card3 = new Card(2,1,3,3); + + assertTrue(card0.isSet(card2, card1)); + assertTrue(card1.isSet(card0, card2)); + assertTrue(card2.isSet(card1, card0)); + assertFalse(card0.isSet(card2, card3)); + assertFalse(card2.isSet(card0, card3)); + assertFalse(card3.isSet(card2, card0)); + } +} \ No newline at end of file diff --git a/src/Deck.java b/src/Deck.java old mode 100755 new mode 100644 index ab3a2a3..cb035c0 --- a/src/Deck.java +++ b/src/Deck.java @@ -2,9 +2,11 @@ import java.io.FileReader; import java.util.StringTokenizer; import java.util.ArrayList; +import java.util.Collections; public class Deck { - // Implement the rest of this class yourself + private ArrayList cards; + private int nextCardIndex = 0; public Deck(String filename) { cards = new ArrayList(81); @@ -42,4 +44,44 @@ public Deck(String filename) { throw new RuntimeException("Error while reading file: " + e.toString()); } } + + public Deck(){ + cards = new ArrayList(81); + int quantity = 1; + int color = 1; + int shading = 1; + int shape = 1; + + for(int i = 1; i <= 3; i++){ + shape = i; + + for(int k = 1; k <= 3; k++){ + color = k; + + for(int y = 1; y <= 3; y++){ + shading = y; + + for(int x = 1; x <= 3; x++){ + quantity = x; + Card card = new Card(quantity, color, shading, shape); + cards.add(card); + } + } + } + } + Collections.shuffle(cards); + } + public boolean hasNext(){ + if(nextCardIndex < cards.size()){ + return true; + } else { + return false; + } + } + + public Card getNext(){ + Card temp = cards.get(nextCardIndex); + nextCardIndex++; + return temp; + } } diff --git a/src/DeckTest.java b/src/DeckTest.java new file mode 100644 index 0000000..ce10eff --- /dev/null +++ b/src/DeckTest.java @@ -0,0 +1,57 @@ +import junit.framework.TestCase; + +public class DeckTest extends TestCase { + public void testZeroArgumentConstructor(){ + Deck deck = new Deck(); + int count = 0; + while(deck.hasNext()){ + deck.getNext(); + count += 1; + } + assertEquals(81, count); + } + + public void testHasNext(){ + Deck deck = new Deck("testDeck.dat"); + // this deck has four cards + assertTrue(deck.hasNext()); + deck.getNext(); + assertTrue(deck.hasNext()); + deck.getNext(); + assertTrue(deck.hasNext()); + deck.getNext(); + assertTrue(deck.hasNext()); + deck.getNext(); + assertFalse(deck.hasNext()); + } + + public void testShuffle(){ + //get five decks + Deck deck1 = new Deck(); + Deck deck2 = new Deck(); + Deck deck3 = new Deck(); + Deck deck4 = new Deck(); + Deck deck5 = new Deck(); + + //get top card + Card card1 = deck1.getNext(); + Card card2 = deck2.getNext(); + Card card3 = deck3.getNext(); + Card card4 = deck4.getNext(); + Card card5 = deck5.getNext(); + + //make sure they are not all equal + assertFalse(card1.equals(card2) && card1.equals(card3) && + card1.equals(card4) && card1.equals(card5)); + + } + + public void testGetNext(){ + + Deck deck = new Deck("testDeck.dat"); + assertEquals(new Card(1,1,1,1), deck.getNext()); + assertEquals(new Card(2,3,1,2), deck.getNext()); + assertEquals(new Card(2,2,1,3), deck.getNext()); + assertEquals(new Card(3,3,2,2), deck.getNext()); + } +} \ No newline at end of file diff --git a/src/Game.java b/src/Game.java new file mode 100644 index 0000000..4081392 --- /dev/null +++ b/src/Game.java @@ -0,0 +1,84 @@ +public class Game{ + private Table t; + private Deck d; + + public Game (){ + d = new Deck(); + t = new Table(); + for(int i =0; i< 12; i++){ + t.add(d.getNext()); + } + + } + + public Game(String filename){ + d = new Deck(filename); + t = new Table(); + for(int i = 0; i< 12 && d.hasNext(); i++){ + t.add(d.getNext()); + + } + + + } + + public int numSets(){ + return t.numSets(); + } + + public int numCards(){ + return t.numCards(); + + } + + + public void playRound(){ + if(isGameOver()){ + return; + } + boolean setRemoved = false; + if(numSets() != 0){ + int length = numCards(); + for(int i= 0; i < length; i++){ + if(setRemoved){ + break; + } + Card icard = t.getCard(i); + for(int j = i + 1; j < length; j++){ + if(setRemoved){ + break; + } + Card jcard = t.getCard(j); + for(int k = j + 1; k < length; k++){ + if(setRemoved){ + break; + } + Card kcard = t.getCard(k); + if(icard.isSet(jcard, kcard)){ + t.removeSet(icard, jcard, kcard); + setRemoved = true; + } + } + } + } + } + if(setRemoved && numCards() >= 12){ + return; + } + + for(int i = 0; i < 3 && d.hasNext(); i++){ + t.add(d.getNext()); + } + + + } + + public boolean isGameOver(){ + if(!d.hasNext() && t.numSets() == 0){ + return true; + } else { + return false; + } + } + +} \ No newline at end of file diff --git a/src/GameTest.java b/src/GameTest.java new file mode 100644 index 0000000..66edac4 --- /dev/null +++ b/src/GameTest.java @@ -0,0 +1,59 @@ +import junit.framework.TestCase; + +public class GameTest extends TestCase { + + public void testGameWithFilename(){ + Game x = new Game("testDeck.txt"); + + assertEquals(4, x.numCards()); + } + + public void testGameWithManyCards(){ + Game x = new Game("testDeck2.txt"); + + assertEquals(12, x.numCards()); + } + + public void testNumSets(){ + Game x = new Game("testDeck2.txt"); + + assertEquals(8, x.numSets()); + + } + + public void testGameOver(){ + Game x = new Game("testDeck.txt"); + + assertTrue(x.isGameOver()); + } + + public void testGameNotOver(){ + Game x = new Game("testDeck2.txt"); + + assertFalse(x.isGameOver()); + } + + public void testPlayRoundFourSet(){ + Game x = new Game("testdeck1.txt"); + assertEquals(12, x.numCards()); + assertEquals(4, x.numSets()); + assertEquals(false,x.isGameOver()); + } + + public void testPlayRoundNoSets(){ + Game x = new Game("testgamenosets.txt"); + assertEquals(12,x.numCards()); + assertEquals(0, x.numSets()); + assertEquals(true,x.isGameOver()); + + } + public void testPlayRound15(){ + Game x = new Game("testgame3.txt"); + assertEquals(12, x.numCards()); + assertEquals(3,x.numSets()); + assertEquals(false,x.isGameOver()); + + } + + +} \ No newline at end of file diff --git a/src/MonteCarlo.java b/src/MonteCarlo.java new file mode 100644 index 0000000..f90e8d8 --- /dev/null +++ b/src/MonteCarlo.java @@ -0,0 +1,45 @@ +public class MonteCarlo{ + + public static void main (String [] args){ + question1(); + question2(); + + } + public static void question1(){ + int numTrials = 1000; + int[] results = new int[numTrials]; + for(int i = 0; i < numTrials; i++){ + Game x = new Game(); + results[i] = x.numSets(); + } + double sum = 0; + for(int i = 0; i < numTrials; i++){ + sum += results[i]; + } + double average = sum/numTrials; + System.out.println("Question 1"); + System.out.println("The number of trials was: " + numTrials); + System.out.println("The average number of sets in 12 cards was: " + average); + } + + public static void question2(){ + int numTrials = 1000; + int[] results = new int[numTrials]; + for(int i =0; i < numTrials; i++){ + Game x = new Game(); + while(!x.isGameOver()){ + x.playRound(); + } + results[i] = x.numCards(); + } + double sum = 0; + for(int i = 0; i < numTrials; i++){ + sum += results[i]; + } + double average = sum/numTrials; + System.out.println("Question 2"); + System.out.println("The number of trials was: " + numTrials); + System.out.println("The average number of cards left at the end: " + average); + } + +} \ No newline at end of file diff --git a/src/Table.java b/src/Table.java new file mode 100644 index 0000000..5f939a7 --- /dev/null +++ b/src/Table.java @@ -0,0 +1,108 @@ +public class Table{ + private TableNode head = null; + + public void add(Card card ){ + TableNode newNode = new TableNode(card); + newNode.setNext(head); + head = newNode; + + } + private boolean isOnTable(Card card){ + TableNode node = head; + boolean foundMatch = false; + while (node != null && !foundMatch) { + if (node.getCard().equals(card)) { + foundMatch = true; + } + else { + node = node.getNext(); + } + } + return foundMatch; + } + + private void removeCard(Card card){ + TableNode lastNode = null; + TableNode node = head; + while (node != null) { + if (node.getCard().equals(card)) { + if (lastNode == null) { + head = node.getNext(); + } else { + lastNode.setNext(node.getNext()); + } + return; + } + lastNode = node; + node = node.getNext(); + } + + } + //removing a card but keeping track of where it is in an a linked list so that it can be called on later + //if the 3 cards don't form a set or if any of the cards are not on the table, return + //otherwise: + //remove card1, card2, and card3, perserving the relative order of the rest of the cards + public void removeSet(Card card1, Card card2, Card card3){ + if(!card2.isSet(card1, card3)){ + return; + } + if(!isOnTable(card1) || !isOnTable(card2) || !isOnTable(card3)){ + return; + } + removeCard(card1); + removeCard(card2); + removeCard(card3); + } + + public int numCards(){ + int count = 0; + TableNode node = head; + while(node != null){ + count += 1; + node = node.getNext(); + } + return count; + } + //if we haven't stored the length of the list, we have to + //iterate through the list and count the cards + //using a while loop + //gives me the length of the list + + //if index is out of bounds, return null + //otherwise: + //iterate through the list index number of times, return + //the node there + public Card getCard(int index){ + int length = numCards(); + if(head == null || index >= length){ + return null; + }else { + TableNode temp = head; + for(int i=0; i < index; i++){ + temp = temp.getNext(); + } + return temp.getCard(); + } + } + //number of sets currently on the table + //get all triples of cards on the table, and check isSet on each one + //need a three deep nested loop!! + public int numSets(){ + int length = numCards(); + int count = 0; + for(int i= 0; i < length; i++){ + Card icard = getCard(i); + for(int j = i + 1; j < length; j++){ + Card jcard = getCard(j); + for(int k = j + 1; k < length; k++){ + Card kcard = getCard(k); + if(icard.isSet(jcard, kcard)){ + count++; + } + } + } + } + return count; + } + +} diff --git a/src/TableNode.java b/src/TableNode.java new file mode 100644 index 0000000..138f03d --- /dev/null +++ b/src/TableNode.java @@ -0,0 +1,21 @@ +public class TableNode { + private Card card; + private TableNode next; + + public TableNode(Card x){ + next = null; + card = x; + } + + public TableNode getNext(){ + return next; + } + + public void setNext(TableNode node){ + next = node; + } + + public Card getCard(){ + return card; + } +} \ No newline at end of file diff --git a/src/TableTest.java b/src/TableTest.java new file mode 100644 index 0000000..354f151 --- /dev/null +++ b/src/TableTest.java @@ -0,0 +1,182 @@ +import junit.framework.TestCase; + +public class TableTest extends TestCase { + + public void testEmptyTable(){ + Table x = new Table(); + + assertEquals(0, x.numCards()); + assertEquals(null, x.getCard(0)); + assertEquals(0, x.numSets()); + + } + + public void testOneCard(){ + Table y = new Table(); + Card card1 = new Card (1,3,3,2); + + y.add(card1); + + assertEquals(1, y.numCards()); + assertEquals(card1, y.getCard(0)); + assertEquals(0, y.numSets()); + } + + public void testTwoCards(){ + Table k = new Table(); + Card card1 = new Card (1,1,1,1); + Card card2 = new Card (2,2,2,1); + + k.add(card1); + k.add(card2); + + assertEquals(2, k.numCards()); + assertEquals(card2, k.getCard(0)); + assertEquals(card1, k.getCard(1)); + assertEquals(0, k.numSets()); + + } + + public void testManyCards(){ + Table z = new Table(); + Card c1 = new Card (1,2,2,2); + Card c2 = new Card (1,1,1,1); + Card c3 = new Card (1,1,1,3); + Card c4 = new Card (1,2,3,1); + Card c5 = new Card (1,1,1,2); + + z.add(c1); + z.add(c2); + z.add(c3); + z.add(c4); + z.add(c5); + + assertEquals(5, z.numCards()); + assertEquals(c5, z.getCard(0)); + assertEquals(c4, z.getCard(1)); + assertEquals(c3, z.getCard(2)); + assertEquals(c2, z.getCard(3)); + assertEquals(c1, z.getCard(4)); + assertEquals(1, z.numSets()); + +} + public void testRemoveSetNotSet(){ + Table z = new Table(); + Card c1 = new Card (1,2,2,2); + Card c2 = new Card (1,1,1,1); + Card c3 = new Card (1,1,1,3); + + + z.add(c1); + z.add(c2); + z.add(c3); + z.removeSet(c1,c2,c3); + + assertEquals(3, z.numCards()); + } + + public void testRemoveSetNotOnTable(){ + Table z = new Table(); + Card c1 = new Card (1,1,1,2); + Card c2 = new Card (1,1,1,1); + Card c3 = new Card (1,1,1,3); + + + z.add(c1); + z.add(c2); + z.removeSet(c1,c2,c3); + + assertEquals(2, z.numCards()); + } + + public void testRemoveSet(){ + Table z = new Table(); + Card c1 = new Card (1,1,1,2); + Card c2 = new Card (1,1,1,1); + Card c3 = new Card (1,1,1,3); + + + z.add(c1); + z.add(c2); + z.add(c3); + z.removeSet(c1,c2,c3); + + assertEquals(0, z.numCards()); + } + + public void testRemoveSetSameOrder(){ + Table z = new Table(); + Card c1 = new Card (1,1,1,2); + Card c4 = new Card (3,3,3,1); + Card c2 = new Card (1,1,1,1); + Card c5 = new Card (2,2,2,2); + Card c3 = new Card (1,1,1,3); + + + z.add(c1); + z.add(c4); + z.add(c2); + z.add(c5); + z.add(c3); + + z.removeSet(c1,c2,c3); + + assertEquals(2, z.numCards()); + assertEquals(c5, z.getCard(0)); + assertEquals(c4, z.getCard(1)); + } + + public void testNumSets(){ + Table e = new Table(); + Card c1 = new Card (1,1,1,1); + Card c2 = new Card (1,1,1,2); + Card c3 = new Card (1,1,1,3); + Card c4 = new Card (1,1,2,3); + Card c5 = new Card (2,2,2,2); + + e.add(c1); + e.add(c2); + e.add(c3); + e.add(c4); + e.add(c5); + + assertEquals(5, e.numCards()); + assertEquals(c1, e.getCard(4)); + assertEquals(c2, e.getCard(3)); + assertEquals(c3, e.getCard(2)); + assertEquals(c4, e.getCard(1)); + assertEquals(c5, e.getCard(0)); + assertEquals(1, e.numSets()); + + } + + public void testNumSetsTwo(){ + Table e = new Table(); + Card c1 = new Card (1,1,1,1); + Card c2 = new Card (1,1,1,2); + Card c3 = new Card (1,1,1,3); + Card c4 = new Card (1,1,2,3); + Card c5 = new Card (2,2,2,2); + Card c6 = new Card (2,2,2,1); + Card c7 = new Card (2,2,2,3); + + e.add(c1); + e.add(c2); + e.add(c3); + e.add(c4); + e.add(c5); + e.add(c6); + e.add(c7); + + assertEquals(7, e.numCards()); + assertEquals(c1, e.getCard(6)); + assertEquals(c2, e.getCard(5)); + assertEquals(c3, e.getCard(4)); + assertEquals(c4, e.getCard(3)); + assertEquals(c5, e.getCard(2)); + assertEquals(c6, e.getCard(1)); + assertEquals(c7, e.getCard(0)); + assertEquals(2, e.numSets()); + + } +} \ No newline at end of file diff --git a/src/testDeck.dat b/src/testDeck.dat new file mode 100644 index 0000000..4254947 --- /dev/null +++ b/src/testDeck.dat @@ -0,0 +1,4 @@ +1 1 1 1 +2 3 1 2 +2 2 1 3 +3 3 2 2 \ No newline at end of file diff --git a/src/testDeck.txt b/src/testDeck.txt new file mode 100644 index 0000000..96402e5 --- /dev/null +++ b/src/testDeck.txt @@ -0,0 +1,4 @@ +1 1 1 1 +2 3 1 2 +2 2 1 3 +3 3 2 2 \ No newline at end of file diff --git a/src/testDeck2.txt b/src/testDeck2.txt new file mode 100644 index 0000000..c9ac5ee --- /dev/null +++ b/src/testDeck2.txt @@ -0,0 +1,13 @@ +1 2 1 2 +3 3 3 3 +1 1 1 1 +2 2 2 2 +1 1 1 2 +3 3 3 1 +1 2 1 1 +2 3 2 2 +2 1 2 1 +3 3 3 2 +2 3 3 3 +1 3 1 3 +1 2 2 1 \ No newline at end of file diff --git a/src/testdeck1.txt b/src/testdeck1.txt new file mode 100644 index 0000000..489b854 --- /dev/null +++ b/src/testdeck1.txt @@ -0,0 +1,12 @@ +1 1 1 1 +1 1 1 2 +1 1 1 3 +3 3 3 3 +2 2 2 2 +2 1 2 1 +2 3 2 3 +3 2 3 2 +3 1 1 1 +2 1 3 3 +3 3 2 1 +2 1 3 2 \ No newline at end of file diff --git a/src/testgame3.txt b/src/testgame3.txt new file mode 100644 index 0000000..1df6046 --- /dev/null +++ b/src/testgame3.txt @@ -0,0 +1,15 @@ +3 2 1 1 +2 3 3 1 +2 3 1 2 +1 1 1 2 +2 3 3 2 +2 2 1 2 +1 1 1 3 +1 3 3 3 +2 1 1 3 +3 1 3 2 +3 2 1 1 +2 1 2 1 +3 1 1 1 +2 3 1 1 +1 1 1 1 \ No newline at end of file diff --git a/src/testgamenosets.txt b/src/testgamenosets.txt new file mode 100644 index 0000000..4666db2 --- /dev/null +++ b/src/testgamenosets.txt @@ -0,0 +1,13 @@ +2 1 2 3 +1 1 2 2 +2 3 2 3 +1 2 3 3 +1 3 1 2 +2 3 3 3 +2 3 3 1 +3 1 1 1 +1 3 3 1 +2 2 3 2 +2 1 1 2 +3 2 3 2 + \ No newline at end of file