Created
March 16, 2015 13:36
-
-
Save ImDevinC/77ff205e4d7d4664b3cd to your computer and use it in GitHub Desktop.
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
Random r = new Random(); | |
int selectedCard = r.nextInt(52) + 1; // 51 is the maximum, 1 is the minimum | |
String suit = ""; | |
String card = ""; | |
int cardNum = 0; | |
if (selectedCard <= 13) { | |
suit = "Hearts"; | |
} else if (selectedcard <= 26) { | |
suit = "Diamonds"; | |
cardNum -= 13; | |
} else if (selectedCard <= 39) { | |
suit = "Clubs"; | |
cardNum -= 26; | |
} else { | |
suit = "Spades"; | |
cardNum -= 39; | |
} | |
switch (cardNum) { | |
case 1: | |
card = "Ace"; | |
case 11: | |
card = "Jack"; | |
case 12: | |
card = "Queen"; | |
case 13: | |
card = "King"; | |
default: | |
card = String.valueOf(cardNum); | |
} | |
System.out.println("You drew a " + card); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment