Ver código fonte

some changes

Nuridalia.Hernandez 5 anos atrás
pai
commit
1b01129532

+ 16
- 15
src/main/java/io/zipcoder/casino/Casino.java Ver arquivo

@@ -5,27 +5,28 @@ import java.util.Scanner;
5 5
 
6 6
 public class Casino {
7 7
     public static void main (String [] args){
8
-        String Start = Console.getStringInput("'Welcome to  the BlackJack Game' \n do you want to play?");
8
+        String Start = Console.getStringInput("'Welcome to  the BlackJack Game' \n do you want to play? Yes or No ");
9
+        String name = Console.getStringInput("what is your name");
10
+        String addMoneyToWallet = Console.getStringInput("How much money do you want to add to your wallet");
9 11
         Integer bet = Console.getIntegerInput("Place your bet");
10 12
         String hit = Console.getStringInput("Do you want to hit 'H' or Stand 'S'");
11 13
         Deck theDeck = new Deck();
12 14
 
13 15
 
14 16
 
17
+    //initiate the player object
18
+        Wallet wallet =new Wallet(0.0, "");
19
+        Hand hand = new Hand (null);
20
+        BlackJackPlayer me = new BlackJackPlayer( wallet, 0.0, hand );
21
+        Dealer dealer = new Dealer(theDeck);
15 22
 
16
-//
17
-//    //initiate the player object
18
-//    BlackJackPlayer me = new Player(0.0, 0.0,);
19
-//    Dealer dealer = new Player("Dealer");
20
-//
21
-//       me.addCard(theDeck.dealNextCard());
22
-//       dealer.addCard(theDeck.dealNextCard());
23
-//       me.addCard(theDeck.dealNextCard());
24
-//       dealer.addCard(theDeck.dealNextCard());
25
-//
26
-//    //print initial hands
27
-//       System.out.println("WELCOME TO THE BLACKJACK GAME!\n");
28
-//       me.printHand(true);
23
+
24
+
25
+
26
+
27
+
28
+        //print initial hands
29
+//       me.printHand(true);y
29 30
 //       dealer.printHand(false);
30 31
 //       System.out.println("\n");
31 32
 //
@@ -40,7 +41,7 @@ public class Casino {
40 41
 //            System.out.print("Hit or Stay? (Enter H or S): ");
41 42
 //            ans = keyword.next();
42 43
 //            System.out.println();
43
-//
44
+////
44 45
 //            if (ans.compareToIgnoreCase("H") == 0){
45 46
 //                //add next card in the deck and store weather player is busted
46 47
 //                meDone = !me.addCard(theDeck.dealNextCard());

+ 1
- 1
src/main/java/io/zipcoder/casino/Console.java Ver arquivo

@@ -8,7 +8,7 @@ public class Console {
8 8
     private static final Scanner scanner = new Scanner( System.in);
9 9
 
10 10
     public static void println (String str){
11
-        System.out.println(str);
11
+        System.out.print(str + "\n");
12 12
 
13 13
     }
14 14
     public static String getStringInput (String prompt){

+ 53
- 0
src/test/java/io/zipcoder/casino/BlackJackPlayer.java Ver arquivo

@@ -0,0 +1,53 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+public class BlackJackPlayer {
7
+
8
+//    @Test
9
+//    public void testGetBet() {
10
+//        //given
11
+//        Hand hand =new Hand(null);
12
+//        Wallet wallet = new Wallet(100.00, "Nury H.");
13
+//        //BlackJackPlayer player = new BlackJackPlayer(wallet, 50,  );
14
+//        double expected = 50;
15
+//        //when
16
+//
17
+//
18
+//        Assert.assertEquals(expected, player.getBet(), 0.01);
19
+
20
+   // }
21
+
22
+    @Test
23
+    public void testAddWinnings() {
24
+        //given
25
+        Wallet wallet = new Wallet(100.00, "Nury H.");
26
+        Player player = new Player(wallet, 50);
27
+        player.bet(50);
28
+        player.setState("wins");
29
+        //when
30
+        if (player.getState().equals("wins")){
31
+            player.addWining();
32
+        }
33
+
34
+
35
+        Assert.assertEquals(150.00, wallet.getMoney(), 0.01);
36
+
37
+    }
38
+    @Test
39
+    public void testSubtractLoss() {
40
+        Wallet wallet = new Wallet(100.00, "Nury H.");
41
+        Player player = new Player(wallet, 50);
42
+
43
+        //when
44
+        if (player.getState().equals("lose")) {
45
+            player.subtractLoss();
46
+        }
47
+
48
+
49
+        Assert.assertEquals(50, wallet.getMoney(), 0.01);
50
+
51
+    }
52
+}
53
+