-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshuffledeck.java
More file actions
76 lines (72 loc) · 2.14 KB
/
shuffledeck.java
File metadata and controls
76 lines (72 loc) · 2.14 KB
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
public class shuffleDeck {
public static void main(String[] args) {
String[] cards = {
"Aceofspades",
"2ofspades",
"3ofspades",
"4ofspades",
"5ofspades",
"6ofspades",
"7ofspades",
"8ofspades",
"9ofspades",
"10ofspades",
"Jackofspades",
"Queenofspades",
"Kingofspades",
"AceofHearts",
"2ofHearts",
"3ofHearts",
"4ofHearts",
"5ofHearts",
"6ofHearts",
"7ofHearts",
"8ofHearts",
"9ofHearts",
"10ofHearts",
"JackofHearts",
"QueenofHearts",
"KingofHearts",
"AceofDiamonds",
"2ofDiamonds",
"3ofDiamonds",
"4ofDiamonds",
"5ofDiamonds",
"6ofDiamonds",
"7ofDiamonds",
"8ofDiamonds",
"9ofDiamonds",
"10ofDiamonds",
"JackofDiamonds",
"QueenofDiamonds",
"KingofDiamonds",
"AceofClubs",
"2ofClubs",
"3ofClubs",
"4ofClubs",
"5ofClubs",
"6ofClubs",
"7ofClubs",
"8ofClubs",
"9ofClubs",
"10ofClubs",
"JackofClubs",
"QueenofClubs",
"KingofClubs"
};
String[] card_random=new String[52];
for (String card : cards) {
System.out.println(card);
}
System.out.println("< == Shuffle ==>");
int i;
for (i = 0; i < cards.length; i++) {
// Generate an index randomly
int index = (int)(Math.random() * cards.length);
String temp = cards[i];
cards[i] = cards[index];
cards[index] = temp;
System.out.println(cards[i]);
}
}
}