From 7ff5e12124aebe9255c7962ce6eb0ef49ceea9c1 Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Tue, 22 Nov 2022 14:07:43 -0600 Subject: Initial commit --- card/Card.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 card/Card.java (limited to 'card/Card.java') 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; + } +} -- cgit v1.2.3