Id: 5357; Nick: n/a; Timestamp: 2008-02-08 08:43:52; Pasted as: Java
Description: n/a
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
import java.util.Random;
 
public class CardDeck {
	private Card[] cards;
	public CardDeck() {
		cards = new Card[52];
		String[] s = {"S","H","D","C"};
		int a=0,b,c;
 
		for (b=0;b<4;b++) {
			for (c=0;c<13;c++) {
				cards[a] = new Card(s[b],c+1);
				a++;
			}
		}
	}
	public Card getCard(int i) {
		return cards[i];
	}
	public CardDeck(boolean shuffle) {
		cards = new Card[52];
		String[] s = {"S","H","D","C"};
		int a=0,b,c;
 
		for (b=0;b<4;b++) {
			for (c=0;c<13;c++) {
				cards[a] = new Card(s[b],c+1);
				a++;
			}
		}
		if (shuffle) {
			Random r = new Random();
			Card temp;
			int i,j;
 
			for (i=0;i<cards.length;i++) {
				j = r.nextInt(51);
 
				temp = cards[i];
				cards[i] = cards[j];
				cards[j] = temp;
			}
		}
	}
}
Options: New, Download,
;
Copyright © 2006 by Zyberdog - Some rights reserved. (Browse/Disclaimer/Stats/About) - Highlighted with GeSHi