Aleena Rose-Mathew 6 years ago
parent
commit
bc8d82d46f

+ 12
- 26
src/main/java/io/zipcoder/casino/Leviathan/Games/HigherCards.java View File

12
     boolean playAgain = true;
12
     boolean playAgain = true;
13
     int bet;
13
     int bet;
14
     int player,croupier;
14
     int player,croupier;
15
+    int totalChips,wageAmount;
15
     public void setBet(int bet) {
16
     public void setBet(int bet) {
16
         this.bet = bet;
17
         this.bet = bet;
17
     }
18
     }
24
          while (playAgain) {
25
          while (playAgain) {
25
              deck.shuffle();
26
              deck.shuffle();
26
              int wageAmount = wageMoney();
27
              int wageAmount = wageMoney();
28
+             aConsole.println("You Got :");
27
              playerDrawingCard();
29
              playerDrawingCard();
30
+             aConsole.println("House Got :");
28
              houseDrawingCard();
31
              houseDrawingCard();
29
-             int totalChips = aPlayer.getTotalChips();
30
-             findWinner(player, croupier, wageAmount);
31
-             if (aPlayer.getTotalChips() > totalChips) {
32
-                 aConsole.println("Congrats ! You Won ");
33
-             } else {
34
-                 aConsole.println("You Lose");
35
-             }
36
-             aConsole.println("Your current available Chips");
37
-             aConsole.println(aPlayer.getTotalChips().toString());
32
+             findWinner(wageAmount,player, croupier);
33
+             aConsole.println("Your current available Chips %d",aPlayer.getTotalChips());
38
              repeat();
34
              repeat();
39
          }
35
          }
40
      }
36
      }
37
+
41
      public void repeat()
38
      public void repeat()
42
      {
39
      {
43
          if((aPlayer.getTotalChips() == 0) )
40
          if((aPlayer.getTotalChips() == 0) )
55
          Card acard = deck.draw();
52
          Card acard = deck.draw();
56
          Rank rank = acard.getRank();
53
          Rank rank = acard.getRank();
57
          player = rank.getValue();
54
          player = rank.getValue();
58
-         String playervalueString=rank.toString();
59
-         String playerFace=rank.getFaceValue();
60
-
61
          Suit suit = acard.getSuit();
55
          Suit suit = acard.getSuit();
62
-         String suitSymbol=suit.getsuitSymbol();
63
-         String suitString = suit.toString();
64
-
65
-         aConsole.println("You got :%s of %s",playervalueString,suitString);
66
-         printCard(suitSymbol,playerFace);
56
+         printCard(suit.getsuitSymbol(),rank.getFaceValue());
67
      }
57
      }
68
      public void houseDrawingCard()
58
      public void houseDrawingCard()
69
      {
59
      {
70
          Card acard2 = deck.draw();
60
          Card acard2 = deck.draw();
71
          Rank rank2 = acard2.getRank();
61
          Rank rank2 = acard2.getRank();
72
          croupier = rank2.getValue();
62
          croupier = rank2.getValue();
73
-         String playervalueString2=rank2.toString();
74
-         String playerFace2=rank2.getFaceValue();
75
-
76
          Suit suit2 = acard2.getSuit();
63
          Suit suit2 = acard2.getSuit();
77
-         String suitString2 = suit2.toString();
78
-         String suitSymbol2=suit2.getsuitSymbol();
79
-
80
-         aConsole.println("House got :%s of %s",playervalueString2,suitString2);
81
-         printCard(suitSymbol2,playerFace2);
64
+         printCard(suit2.getsuitSymbol(),rank2.getFaceValue());
82
      }
65
      }
83
 
66
 
84
-    public void findWinner(int player,int croupier,int wageAmount)
67
+    public void findWinner(int wageAmount,int player,int croupier)
85
     {
68
     {
86
         if (player > croupier) {
69
         if (player > croupier) {
70
+            aConsole.println("Congrats ! You Won ");
87
             int[] change = {aPlayer.getTally()[0] + 1, aPlayer.getTally()[1]};
71
             int[] change = {aPlayer.getTally()[0] + 1, aPlayer.getTally()[1]};
88
             aPlayer.setTally(change);
72
             aPlayer.setTally(change);
89
            aPlayer.setTotalChips(aPlayer.getTotalChips()+ wageAmount);
73
            aPlayer.setTotalChips(aPlayer.getTotalChips()+ wageAmount);
90
         }
74
         }
91
         else {
75
         else {
76
+            aConsole.println("You Lose");
92
             int[] change = {aPlayer.getTally()[0], aPlayer.getTally()[1] + 1};
77
             int[] change = {aPlayer.getTally()[0], aPlayer.getTally()[1] + 1};
93
             aPlayer.setTally(change);
78
             aPlayer.setTally(change);
94
             aPlayer.setTotalChips(aPlayer.getTotalChips()- wageAmount);
79
             aPlayer.setTotalChips(aPlayer.getTotalChips()- wageAmount);
95
         }
80
         }
81
+
96
         aConsole.println("Your current Win/Loss Ratio is " + aPlayer.getTally()[0] + "-" + aPlayer.getTally()[1] + "\n");
82
         aConsole.println("Your current Win/Loss Ratio is " + aPlayer.getTally()[0] + "-" + aPlayer.getTally()[1] + "\n");
97
     }
83
     }
98
 
84
 

+ 7
- 3
src/test/java/io/zipcoder/casino/HigherCardsTest.java View File

5
 import org.junit.Assert;
5
 import org.junit.Assert;
6
 import org.junit.Test;
6
 import org.junit.Test;
7
 
7
 
8
+import static org.junit.Assert.assertFalse;
8
 import static org.junit.Assert.assertTrue;
9
 import static org.junit.Assert.assertTrue;
9
 
10
 
10
 
11
 
11
 public class HigherCardsTest {
12
 public class HigherCardsTest {
12
     Player aplayer =new Player("Aleena",2000, 21);
13
     Player aplayer =new Player("Aleena",2000, 21);
14
+
13
     HigherCards higherCards=new HigherCards(aplayer);
15
     HigherCards higherCards=new HigherCards(aplayer);
14
 
16
 
15
     @Test
17
     @Test
16
     public void testFindAWinner()
18
     public void testFindAWinner()
17
     {
19
     {
18
-        Player aplayer =new Player("Aleena",2000, 21);
19
-        HigherCards higherCards=new HigherCards(aplayer);
20
+        //Player aplayer =new Player("Aleena",2000, 21);
21
+        //HigherCards higherCards=new HigherCards(aplayer);
20
 
22
 
21
         int expected=2500;
23
         int expected=2500;
22
-        higherCards.findWinner(10,2,500);
24
+        higherCards.findWinner(500,10,2);
23
         int actual=aplayer.getTotalChips();
25
         int actual=aplayer.getTotalChips();
24
         Assert.assertEquals(actual,expected);
26
         Assert.assertEquals(actual,expected);
25
     }
27
     }
32
         //Result
34
         //Result
33
         assertTrue(higherCards.badBet());
35
         assertTrue(higherCards.badBet());
34
     }
36
     }
37
+
38
+
35
 }
39
 }