public class Card { public Card(CardRank rank, CardSuit suit){ // TODO: Implemen
ID: 3545458 • Letter: P
Question
public class Card
{
public Card(CardRank rank, CardSuit suit){
// TODO: Implement this constructor.
}
/**
* @return the card's rank
*/
public CardRank getRank(){
// TODO: Implement this method.
return null;}
/**
* @return the card's suit
*/
public CardSuit getSuit(){
// TODO: Implement this method.
return null;
}
}
/////////////////////////////////////////
public enum CardRank
{
TWO(1),
THREE(2),
FOUR(3),
FIVE(4),
SIX(5),
SEVEN(6),
EIGHT(7),
NINE(8),
TEN(9),
JACK(10),
QUEEN(11),
KING(12),
ACE(13);
private final int value;
/**
* Constructor sets the rank.
* @param value
*/
private CardRank(int value)
{
this.value = value;
}
/**
* @param other the other rank to compare this one with
* @return true if this rank beats the other
*/
public boolean isHigherThan(CardRank other)
{
return value > other.value;
}
/**
* @return the numerical value in the range of 1 to 13
*/
public int getValue()
{
return value;
}
}
////////////////////////////////////////
public enum CardSuit
{
CLUB, DIAMOND, HEART, SPADE;
}
/////////////////////////////////////////
public interface PokerHand
{
/**
* @param another poker hand
* @return true if this hand beats the other hand, false if the other beats this
* hand or if they are the same
*/
boolean beats(PokerHand other);
/**
* @return the five cards from the hand
*/
Card[] getCards();
}
/////////////////////////////////////
public class Poke implements PokerHand
{
/**
* Default constructor
* @param cards the five cards
*/
public Poke(Card[] cards)
{
// TODO: Implement this constructor.
}
@Override
public boolean beats(PokerHand other)
{
// TODO Implement this method.
return false;
}
@Override
public Card[] getCards()
{
// TODO Implement this method.
return null;
}
}
Explanation / Answer
If you could provide me with a brief description on what each method is supposed to do then I would be happy to assist you.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.