Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please fill in the //TODO Here is the description of the game: when the game starts, you deal five cards face down. You goal is

image text in transcribed please fill in the //TODO
Here is the description of the game: when the game starts, you deal five cards face down. You goal is to achieve a high score as possible. Your score is only includes cards that are face up
The game is played by flipping cards (either from fave down or to face up to face down) The challenge us that you get onlu a fixed number of flips and then game is over.
Here is the card class:
public class Card {
// min/max for the card number range
private static final int MIN_NUMBER = 1;
private static final int MAX_NUMBER = 13;
private int number;
private String suit;
private boolean faceUp = false; // whether the card is face up
public Card(int tempNumber, String tempSuit){
number = tempNumber;
suit = tempSuit.toLowerCase();
if( !isValidSuit(suit) ){
System.out.println(tempSuit + "Is not a valid suit!");
System.out.println("Must be one of: clubs, diamonds, hearts or spades");
System.out.println("Defaulting to hearts");
suit = "hearts";
}
if( !isValidNumber(number) ){
System.out.println(tempNumber + "Is not a valid number!");
System.out.println("Must be between " + MIN_NUMBER + " and " + MAX_NUMBER);
System.out.println("Defaulting to 1");
number = 1;
}
}
public String getSuit(){
return suit;
}
public String getNumber(){
if( number == 1 ){
return "Ace";
}else if( number >= 2 && number
return Integer.toString(number);
}else if( number == 11 ){
return "Jack";
}else if( number == 12 ){
return "Queen";
}else{
return "King";
}
}
public boolean isFaceUp(){
return faceUp;
}
public void flip(){
faceUp = !faceUp;
}
public String toString(){
return getNumber() + " of " + getSuit();
}
public void cheat(){
number = 1; // ACE!
}
private boolean isValidNumber(int num){
return num >= MIN_NUMBER && num
}
private boolean isValidSuit(String s){
return s.equals("spades") ||
s.equals("hearts") ||
s.equals("clubs") ||
s.equals("diamonds");
}
/**
* The value of this card for the flippy card game.
* Numbers have their number as the value, Ace is 11,
* and Jack, Queen, and King are 10.
*
* @return the flippy card value
*/
public int getFlippyCardValue(){
//TODO: Fill in good stuff here!
return 0;
}
/**
* Whether the suit is red or not.
*
* @return whether or not the card is red
*/
public boolean isRedCard(){
//TODO: Fill in good stuff here!
return false;
}
}
Warmut Bag.Java Tokenjava Person.java Warmup.java 157 Keep track of the cards and and answer questions for the card game Red cards hearts and diamonds and positive points, while black cards . (clubs and spades) and negative points. Cards 2-10 points worth Teir face valut, Jack, Queen and King 10 and Act 11. public class FlippyCards private Card) cards // the cards for the same ye 6 Create a new inox, card game state para nuncards number of cards in the game 9 00 public FlippyCards(int nuncards) { cards new Card Inu Cards 1/ To Fill in good stuff here 3 5 Vee Flip the card over at this index. Card Indices start at and go up the cards.length-1 param cardIndex the index of the card to flip over public void flipCardint cardIndex) 1/TOO: Fall in good stuff here! Hee Calculate the best possible score for the current cards. return the optimal score public int calculatetassers //T0001 Thi in good stuff here return 0; 3 - Calculate the line card score for the cards that are face up. return the finoy card score for fast cards public int facelipTotali) /TOO! Fill in good stuff heret return; rrado Calculate the liney, card score for the cards that are face down. return the card score for fed cards public int faceDownTotalt 1/1000: FALL I good stuff here! return 0; > //T0001 Add toString method here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago