summaryrefslogtreecommitdiff
path: root/card/Card.java
blob: fb4231400eabf732477f23dab3ac8eb5991a770a (plain)
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
package card;

public class Card {
	private int value;
	private Suit suit;

	public Card(int value, Suit suit) {
		this.value = value;
		this.suit = suit;
	}

	public int getValue() {
		return this.value;
	}

	public Suit getSuit() {
		return this.suit;
	}

	public String displayCard() {
		String name = "";
		if (this.value < 1 || this.value > 13) {
			name += "UNKNOWN";
		} else if (this.value > 1 && this.value < 11) {
			name += this.value;
		} else {
			switch (this.value) {
				case 1:
					name += "ace";
					break;
				case 11:
					name += "jack";
					break;
				case 12:
					name += "queen";
					break;
				case 13:
					name += "king";
					break;
				default:
					name += "UNKNOWN";
				}
		}
		switch (this.suit) {
			case CLUBS:
				name += " of clubs";
				break;
			case DIAMONDS:
				name += " of diamonds";
				break;
			case HEARTS:
				name += " of hearts";
				break;
			case SPADES:
				name += " of spades";
				break;
		}
		return name;
	}
}