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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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 + " ]";
}
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply