-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDeck.java
More file actions
54 lines (42 loc) · 1.02 KB
/
Copy pathDeck.java
File metadata and controls
54 lines (42 loc) · 1.02 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
package blackJack;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
class Card{
private char color;
private String rank;
public Card(char color, String rank) {
// TODO Auto-generated constructor stub
this.color = color;
this.rank = rank;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return String.valueOf(color) + rank;
}
public char getColor() {
return color;
}
public String getRank() {
return rank;
}
}
public class Deck {
Card[] card = new Card[52];
public Deck() {
// TODO Auto-generated constructor stub
char[] colors = {'\u2660', '\u2665', '\u2663', '\u2666'};
String[] ranks = {"2", "3", "4", "5", "6","7", "8", "9", "10", "J", "Q", "K", "A"};
int k = 0;
for(int i = 0; i < colors.length; i++)
for(int j = 0; j < ranks.length; j++)
{
card[k] = new Card(colors[i], ranks[j]);
k++;
}
List<Card> list = Arrays.asList(card);
Collections.shuffle(list);
System.out.println("已经洗好牌了");
}
}