blob: a828e52bdd7937f5df383197e25f3c97a14049ec (
plain) (
blame)
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
|
import java.util.Random; //for randomness
public class Deck {
// data member
private int[] deckFace = new int[20];
private int[] deckSuit = new int[20];
// Constructors
//accepts suit and face
public Deck() {
for(int i=0;i<20;i++){
Random random = new Random();
deckFace[i] = random.nextInt(14); //1-10 are as expected, 11 is Jack, 12 is Queen, 13 is King, 14 is Joker
deckSuit[i] = random.nextInt(4); //Card order is highest to lowest. 1 is hearts 4 is spades.
}
}
void printDeck(){
for(int i=0;i<20;i++){
System.out.println("Card " + i + " has a Face of " + deckFace[i] + " and a Suit of " + deckSuit[i]);
}
}
void shuffle(){
for(int i=0;i<20;i++){
Random random = new Random();
deckFace[i] = random.nextInt(14); //1-10 are as expected, 11 is Jack, 12 is Queen, 13 is King, 14 is Joker
deckSuit[i] = random.nextInt(4); //Card order is highest to lowest. 1 is hearts 4 is spades.
}
}
}
|