summaryrefslogtreecommitdiff
path: root/card/Card.java
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2022-11-22 14:07:43 -0600
committerMichael Hunteman <michael@huntm.net>2022-11-22 14:07:43 -0600
commit7ff5e12124aebe9255c7962ce6eb0ef49ceea9c1 (patch)
tree9ea31987bb6dd64c3d66e38ccbb5dc56a8fcdecf /card/Card.java
Initial commit
Diffstat (limited to 'card/Card.java')
-rw-r--r--card/Card.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/card/Card.java b/card/Card.java
new file mode 100644
index 0000000..fb42314
--- /dev/null
+++ b/card/Card.java
@@ -0,0 +1,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;
+ }
+}