소스 검색

some changes

부모
커밋
1b01129532
3개의 변경된 파일70개의 추가작업 그리고 16개의 파일을 삭제
  1. 16
    15
      src/main/java/io/zipcoder/casino/Casino.java
  2. 1
    1
      src/main/java/io/zipcoder/casino/Console.java
  3. 53
    0
      src/test/java/io/zipcoder/casino/BlackJackPlayer.java

+ 16
- 15
src/main/java/io/zipcoder/casino/Casino.java 파일 보기

5
 
5
 
6
 public class Casino {
6
 public class Casino {
7
     public static void main (String [] args){
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
         Integer bet = Console.getIntegerInput("Place your bet");
11
         Integer bet = Console.getIntegerInput("Place your bet");
10
         String hit = Console.getStringInput("Do you want to hit 'H' or Stand 'S'");
12
         String hit = Console.getStringInput("Do you want to hit 'H' or Stand 'S'");
11
         Deck theDeck = new Deck();
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
 //       dealer.printHand(false);
30
 //       dealer.printHand(false);
30
 //       System.out.println("\n");
31
 //       System.out.println("\n");
31
 //
32
 //
40
 //            System.out.print("Hit or Stay? (Enter H or S): ");
41
 //            System.out.print("Hit or Stay? (Enter H or S): ");
41
 //            ans = keyword.next();
42
 //            ans = keyword.next();
42
 //            System.out.println();
43
 //            System.out.println();
43
-//
44
+////
44
 //            if (ans.compareToIgnoreCase("H") == 0){
45
 //            if (ans.compareToIgnoreCase("H") == 0){
45
 //                //add next card in the deck and store weather player is busted
46
 //                //add next card in the deck and store weather player is busted
46
 //                meDone = !me.addCard(theDeck.dealNextCard());
47
 //                meDone = !me.addCard(theDeck.dealNextCard());

+ 1
- 1
src/main/java/io/zipcoder/casino/Console.java 파일 보기

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

+ 53
- 0
src/test/java/io/zipcoder/casino/BlackJackPlayer.java 파일 보기

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
+