repl.it
@imigames/

black jack 2.0

Java

No description

fork
loading
Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import java.util.Random;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

class Main {

  static Random r = new Random();
  static Scanner input = new Scanner(System.in);
  static int deal;
  static int player;
  static int player2;
  static String player_print;
  static int dealer;
  static int dealer2;
  static String dealer_print;

  public static void main(String[] args) {
    System.out.println("Hello, let's play a game of Black jack!");
    time(2000);
    System.out.println("Press 1 to deal:");
    
    while(true){
      deal=input.nextInt();
      for ( int n = 1 ; n <= 2 ; n = n+1 ){
    if (deal== 1 && player2<22 && n == 1){
      player = 1+r.nextInt(14);
      dealer = 1+r.nextInt(14);
      player2=player+player2;
      dealer2=dealer+dealer2;
      if (player ==1){
       player_print = "Ace";
    }
      else if(player == 2){
       player_print = "Two";
    }
      else if(player == 3){
       player_print = "Three";
    }
      else if(player == 4){
       player_print = "Four";
    }
      else if(player == 5){
       player_print = "Five";
    }
    else if(player == 6){
       player_print = "Six";
    }
    else if(player == 7){
       player_print = "Seven";
    }
    else if(player == 8){
       player_print = "Eight";
    }
    else if(player == 9){
       player_print = "Nine";
    }
    else if(player == 10){
       player_print = "Ten";
    }
    else if(player == 11){
       player_print = "Ace";
    }
    else if(player == 12){
       player_print = "Jack";
    }
    else if(player == 13){
       player_print = "Queen";
    }
    else if(player == 14){
       player_print = "King";
    }
    //dealer Chose
    if (dealer ==1){
       dealer_print = "Ace";
    }
    else if(dealer == 2){
       dealer_print = "Two";
    }
    else if(dealer == 3){
       dealer_print = "Three";
    }
    else if(dealer == 4){
       dealer_print = "Four";
    }
    else if(dealer == 5){
       dealer_print = "Five";
    }
    else if(dealer == 6){
       dealer_print = "Six";
    }
    else if(dealer == 7){
       dealer_print = "Seven";
    }
    else if(dealer == 8){
       dealer_print = "Eight";
    }
    else if(dealer == 9){
       dealer_print = "Nine";
    }
    else if(dealer == 10){
       dealer_print = "Ten";
    }
    else if(dealer == 11){
       dealer_print = "Ace";
    }
    else if(dealer == 12){
       dealer_print = "Jack";
    }
    else if(dealer == 13){
       dealer_print = "Queen";
    }
    else if(dealer == 14){
       dealer_print = "King";
    }
      System.out.println("******************************");
      System.out.println("Player draw a "+player_print);
      time(1000);
      System.out.println("The value for player is :"+player2);
      System.out.println("and");
      time(1000);
      System.out.println("Dealer draw a "+dealer_print);
      System.out.println("The value for dealer is :"+dealer2);
      time(2000);
      System.out.println("Press 1 to deal one more card or 2 to stop");
    }
    else if (player2 >21 || dealer2 ==21){
      System.out.println("You loose!!");
      break;
    }
    else if (player2 == 21){
      System.out.println("You won!!!");
      break;
    }
    else if (deal== 2)
    }

    }





  }


  public static void time(int x){
    try 
{
    Thread.sleep(x);
} 
catch(InterruptedException e)
{
     // this part is executed when an exception (in this example InterruptedException) occurs
}
  }
}