public static void main(String[] args) { PokerGame pokerGame = new PokerGame(); pokerGame.play(); }
// Tests for PokerGames - many of these tests rely on information created at the start of this // function it // ended up feeling more redundant to rewrite this function into individual function tests when // half // the method would of had to have been coppy and pasted over anyways for these tests to run as // such // Poker game tests are all within a single well commented function @Test public void testGames() { // Setting up variables for testing PokerGame myGame = new PokerGame(); myGame.players = new PokerPlayer[4]; myGame.numPlayers = 4; for (int i = 0; i < 4; i++) { myGame.players[i] = new PokerPlayer(); } myGame.players[0].setPlayer("Player1 TwoHearts ThreeHearts FourHearts FiveHearts SixHearts"); myGame.players[1].setPlayer("Player2 TwoHearts TwoDiamonds NineClubs JackClubs KingClubs"); myGame.players[2].setPlayer( "Player3 ThreeDiamonds FourDiamonds FiveDiamonds SixDiamonds SevenDiamonds"); myGame.players[3].setPlayer("Player4 TwoClubs ThreeClubs TwoSpades FourSpades SixClubs"); for (int i = 0; i < 4; i++) { myGame.players[i].sortHand(); myGame.players[i].getHandValue(); } // End Variable Setup // testing flip players myGame.flipPlayers(0, 1); assertEquals("Player2", myGame.players[0].getID()); // Testing Check High card myGame.checkHighCards(0, 3); assertEquals("Player2", myGame.players[3].getID()); // Testing the hand sorting function myGame.sortHands(); assertEquals("Player4", myGame.players[0].getID()); assertEquals("Player2", myGame.players[1].getID()); assertEquals("Player1", myGame.players[2].getID()); assertEquals("Player3", myGame.players[3].getID()); // testing a checker for counting number of words in the input assertEquals( 0, myGame.checkInputLength("Player4 TwoClubs ThreeClubs TwoSpades FourSpades SixClubs")); assertEquals(-1, myGame.checkInputLength("Player4 ThreeClubs TwoSpades FourSpades SixClubs")); assertEquals( -1, myGame.checkInputLength( "Player4 FourClubs EightSpades TwoClubs TwoSpades FourSpades SixClubs")); assertEquals( -1, myGame.checkInputLength("Player4 TwoClubs ThreeClubs TwoSpades FourSpades SixClubs")); assertEquals(-1, myGame.checkInputLength("Player4 TwoClubs TwoSpades FourSpades SixClubs")); // testing a checker for ID's to ensure they are valid and an the first position and not already // taken // for the purposes of this assignment a valid id is one that has not been taken and is not a // card i.e. TwoClubs // will not be accepted but Player1 or 09872634 or ID1 etc will be accepted // new ID assertEquals(0, myGame.checkID("Player7", 4)); // used ID assertEquals(-1, myGame.checkID("Player4", 4)); // improper id assertEquals(-1, myGame.checkID("TwoClubs", 4)); // checking each card entered is indeed a card and is unique // new unique card assertEquals(0, myGame.checkCard("KingDiamonds", 4, 5)); // used card assertEquals(-1, myGame.checkCard("TwoHearts", 4, 5)); // unique card up to position 2, 3 in list assertEquals(0, myGame.checkCard("JackClubs", 2, 3)); // used card assertEquals(-1, myGame.checkCard("JackClubs", 2, 4)); // not a card assertEquals(-1, myGame.checkCard("thClubs", 4, 4)); // lastly I combine my checking fucntions into one fucntion that goes through an entire input // string looking for mistakes assertEquals( 0, myGame.checkInput("Player9 FiveSpades SixSpades SevenSpades EightSpades NineSpades", 4)); assertEquals( -1, myGame.checkInput("Player1 TwoClubs ThreeClubs TwoSpades FourSpades SixClubs", 4)); assertEquals( -1, myGame.checkInput("TwoSpades TwoClubs ThreeClubs TwoSpades FourSpades SixClubs", 4)); assertEquals(-1, myGame.checkInput("Player9 ThreeClubs TwoSpades FourSpades SixClubs", 4)); assertEquals( -1, myGame.checkInput("Player9 TwoSpades SixSpades SevenSpades EightSpades NineSpades", 4)); }