-
-
Save anonymous/71d1baf86eb8354cfbfe to your computer and use it in GitHub Desktop.
blackjack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NewBlackJack | |
{ | |
public static void main (String[] args) | |
{ | |
int chips = 200; | |
boolean game = true; | |
Scanner keyboard = new Scanner (System.in); | |
Random r = new Random(); | |
while (game == true) | |
{ | |
System.out.println("You have " + chips + " chips."); | |
System.out.println("Place your bet."); | |
int bet = keyboard.nextInt(); | |
System.out.println("You bet " + bet + " chips."); | |
int[] firstCards = genCards(0); | |
System.out.println(firstCards); | |
} | |
} | |
public static int[] genCards(int genWhat) | |
{ | |
Random r = new Random(); | |
if (genWhat == 0) | |
{ | |
int[] cards = {0,0,0,0,0,0}; | |
for (int i = 0; i < 4; i += 1) | |
{ | |
cards[i] = 2 + r.nextInt(13); | |
if (cards[i] > 11) | |
{ | |
cards[i] = 10; | |
} | |
if (cards[i] == 11) | |
{ | |
if (cards[i] < 2) | |
{ | |
cards[5] += 1; | |
} | |
else | |
{ | |
cards[6] += 1; | |
} | |
} | |
} | |
System.out.println(cards); | |
return cards; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment