diff options
Diffstat (limited to 'card')
-rw-r--r-- | card/Card$1.class | bin | 0 -> 661 bytes | |||
-rw-r--r-- | card/Card.class | bin | 0 -> 1351 bytes | |||
-rw-r--r-- | card/Card.java | 60 | ||||
-rw-r--r-- | card/Suit.class | bin | 0 -> 883 bytes | |||
-rw-r--r-- | card/Suit.java | 8 |
5 files changed, 68 insertions, 0 deletions
diff --git a/card/Card$1.class b/card/Card$1.class Binary files differnew file mode 100644 index 0000000..2e6a9e7 --- /dev/null +++ b/card/Card$1.class diff --git a/card/Card.class b/card/Card.class Binary files differnew file mode 100644 index 0000000..89c0106 --- /dev/null +++ b/card/Card.class 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; + } +} diff --git a/card/Suit.class b/card/Suit.class Binary files differnew file mode 100644 index 0000000..0450003 --- /dev/null +++ b/card/Suit.class diff --git a/card/Suit.java b/card/Suit.java new file mode 100644 index 0000000..f31de7e --- /dev/null +++ b/card/Suit.java @@ -0,0 +1,8 @@ +package card; + +public enum Suit { + CLUBS, + DIAMONDS, + HEARTS, + SPADES +} |