Question: Using Java, I need to make a card class that uses the constructor : public Card(Rank rank, Suit suit). And Methods: public Rank getRank() Returns
Using Java, I need to make a card class that uses the constructor :
public Card(Rank rank, Suit suit).
And Methods:
public Rank getRank() Returns the rank of this card: one of ACE through KING.
public Suit getSuit() Returns the suit of this card, one of CLUBS, SPADES, HEARTS, or DIAMONDS.
public boolean isFaceUp() Returns true if the card is face-up, false if not.
public boolean isBlack() Returns true if the card is black, false if not. Note: clubs and spades are black, hearts and diamonds are red.
public void setFaceUp(boolean faceUp) Sets the face-up status of the card.
Along with these, I was given enumerations for Rank and Suit:
/** Suits in a standard deck of cards. */
public enum Suit { CLUBS, SPADES, HEARTS, DIAMONDS; }
/** Ranks of cards */
public enum Rank { ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING; }
And um... yeah. I have no idea how I'm supposed to code those methods with this given information.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
