Page 1 of 1

Create a deck of cards public class Card { /** * Obvious. */ enum Suit { HEARTS, CLUBS,

Posted: Fri Apr 29, 2022 6:32 am
by answerhappygod
Create a deck of cards
public class Card {
/**
* Obvious.
*/
enum Suit {
HEARTS,
CLUBS,
DIAMONDS,
SPADES,
NONE
}
/**
* Obvious.
*/
enum Value {
JOKER,
ACE,
KING,
QUEEN,
JACK,
_10,
_9,
_8,
_7,
_6,
_5,
_4,
_3,
_2
}
/**
* Obvious.
*/
private Suit suit;
/**
* Obvious.
*/
private Value value;
/**
* Const.
*
* @param suit The SUITE of the card
* @param value The VALUE of the card.
*/
public Card(final Suit suit, final Value value)
{
this.suit = suit;
this.value = value;
}
/**
* Obvious.
*/
public Suit getSuit() {
return this.suit;
}
/**
* Obvious.
*/
public Value getValue() {
return value;
}
/**
* Obvious.
*/
public boolean equals(final Card card) {
if (card.value == this.value &&
card.suit == this.suit) {
return true;
}
return false;
}
@Override
public String toString() {
return "[ Suit: " + this.suit + ",
Value: " + value + " ]";
}
}