Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE C++ and includes Win Fibo Solitaire as option 5 Welcome to Fibonacci Solitaire! This game uses one standard deck of cards. Here are the

image text in transcribedimage text in transcribedimage text in transcribed

USE C++ and includes "Win Fibo Solitaire" as option 5

Welcome to Fibonacci Solitaire! This game uses one standard deck of cards. Here are the rules: 1) Take the top card from the deck and place it face up on the table. 2) The Sum is now the value of that card ( Ace =1,2=2,10=10, Jack =10, Queen =10, King =10) 3) If the Sum is a Fibonacci number, discard that pile, and start over at instruction \#1 4) If the Sum is not Fibonacci, take the next card from the top of the deck and place it on top of the card pile on the table. 5) The Sum is now the sum of all cards in the pile on the table. 6) Go to instruction #3. Continue to play the game, keeping track of how many piles you have created that are Fibonacci. If the last card from the deck gives you a Fibonacci pile, then you win! Write the word "Winner" on the screen and show how many Fibonacci piles there were. If the last card from the deck does not give you a Fibonacci pile, then you lose. Write the word "Loser" on the screen. These 2 screen shots show possible winner and loser hands. When you acquire a Fibonacci pile, print out the value (Fibonacci number) and start over on the next line. Losing game: Playing Fibonacci Solitaire!!! QH,2H,6S,2S,6D,5D,3H, Fibo: 34 5S,Fibo:5 5H,Fibo:5 10H,4D,7H, Fibo: 21 8C, Fibo: 8 4C, AC, Fibo: 5 2C, Fibo: 2 8S, Fibo:8 AD, Fibo: 1 JH,6C,3D,QC,10S,7D,AS,7S,2D,9D,JD,4H,10C,Fibo:89 3C, Fibo:3 7C, 4S,KH, Fibo: 21 JS, 9C, JC, QS, 8H, 8D, Fibo: 55 KC,6H,QD,KD,5C,AH,3S,KS,Fibo:55 10D, 9S, 9H, Last Pile NOT Fibo: 28 Loser in 15 piles! (Notice that I had to play 121 games to win) You will have 2 classes: 1) The Deck class which will create and manage the deck of cards 2) The Card class which create and manage cards The main logic of the program will be in the main function. You will use the Card class and the Deck class to play the game. Here the methods you will need to create. You are restricted to using these functions only. public class Deck public Deck( ) // constructor which creates a deck of 52 cards. Ace of Spades on top, followed by the rest of the spades in order, followed by Hearts, Diamonds and Clubs. public void resetDeck(); // reset the deck so it looks like a new deck. public Card deal( ) // deal a card from the top of the deck. public void shuffle( ) // shuffle the cards in the deck. public bool isEmpty( )// true is deck is empty, false if the deck is not empty public void show ();// show all the cards in the deck: 13 columns and 4 rows. public class Card public Card( ) // create a "default" card public Card( char r, char s ) // constructor to create a card, setting the rank and suit public void setCard(char r, char s ) //set existing card to new values public int getValue( )// return the point value of the card. Ace =1,2 thru 10, Jack =10, Queen =10, King =10 public void show( ) // show the card using 2 fields... Ace of Spade:AS, Ten of Diamond:10D, Queen of Heart:QH, Three of Club:3C. (If you want to get fancy, you can use these symbols for the suit ,,, ) Welcome to Fibonacci Solitaire! 1) Create New Deck 2) Shuffle Deck 3) Display Deck 4) Play Fibo Solitaire Internal 5) Win Fibo Solitaire 6) Exit Creae New Deck will create an unshuffled deck in the following order: Spades, Hearts, Diamonds, Clubs... Ace, 2,3,,10, Jack, Queen, King Display Deck will display all cards in a grid: 13 columns by 4 rows. Shuffle Deck will randomly shuffle all cards in the deck. Play Fibo Solitaire will play the game as described above. Win Fibo Solitaire will automatically continue to play until the person wins and also keep track of how many games were play to get the win Exit will exit the program. Welcome to Fibonacci Solitaire! This game uses one standard deck of cards. Here are the rules: 1) Take the top card from the deck and place it face up on the table. 2) The Sum is now the value of that card ( Ace =1,2=2,10=10, Jack =10, Queen =10, King =10) 3) If the Sum is a Fibonacci number, discard that pile, and start over at instruction \#1 4) If the Sum is not Fibonacci, take the next card from the top of the deck and place it on top of the card pile on the table. 5) The Sum is now the sum of all cards in the pile on the table. 6) Go to instruction #3. Continue to play the game, keeping track of how many piles you have created that are Fibonacci. If the last card from the deck gives you a Fibonacci pile, then you win! Write the word "Winner" on the screen and show how many Fibonacci piles there were. If the last card from the deck does not give you a Fibonacci pile, then you lose. Write the word "Loser" on the screen. These 2 screen shots show possible winner and loser hands. When you acquire a Fibonacci pile, print out the value (Fibonacci number) and start over on the next line. Losing game: Playing Fibonacci Solitaire!!! QH,2H,6S,2S,6D,5D,3H, Fibo: 34 5S,Fibo:5 5H,Fibo:5 10H,4D,7H, Fibo: 21 8C, Fibo: 8 4C, AC, Fibo: 5 2C, Fibo: 2 8S, Fibo:8 AD, Fibo: 1 JH,6C,3D,QC,10S,7D,AS,7S,2D,9D,JD,4H,10C,Fibo:89 3C, Fibo:3 7C, 4S,KH, Fibo: 21 JS, 9C, JC, QS, 8H, 8D, Fibo: 55 KC,6H,QD,KD,5C,AH,3S,KS,Fibo:55 10D, 9S, 9H, Last Pile NOT Fibo: 28 Loser in 15 piles! (Notice that I had to play 121 games to win) You will have 2 classes: 1) The Deck class which will create and manage the deck of cards 2) The Card class which create and manage cards The main logic of the program will be in the main function. You will use the Card class and the Deck class to play the game. Here the methods you will need to create. You are restricted to using these functions only. public class Deck public Deck( ) // constructor which creates a deck of 52 cards. Ace of Spades on top, followed by the rest of the spades in order, followed by Hearts, Diamonds and Clubs. public void resetDeck(); // reset the deck so it looks like a new deck. public Card deal( ) // deal a card from the top of the deck. public void shuffle( ) // shuffle the cards in the deck. public bool isEmpty( )// true is deck is empty, false if the deck is not empty public void show ();// show all the cards in the deck: 13 columns and 4 rows. public class Card public Card( ) // create a "default" card public Card( char r, char s ) // constructor to create a card, setting the rank and suit public void setCard(char r, char s ) //set existing card to new values public int getValue( )// return the point value of the card. Ace =1,2 thru 10, Jack =10, Queen =10, King =10 public void show( ) // show the card using 2 fields... Ace of Spade:AS, Ten of Diamond:10D, Queen of Heart:QH, Three of Club:3C. (If you want to get fancy, you can use these symbols for the suit ,,, ) Welcome to Fibonacci Solitaire! 1) Create New Deck 2) Shuffle Deck 3) Display Deck 4) Play Fibo Solitaire Internal 5) Win Fibo Solitaire 6) Exit Creae New Deck will create an unshuffled deck in the following order: Spades, Hearts, Diamonds, Clubs... Ace, 2,3,,10, Jack, Queen, King Display Deck will display all cards in a grid: 13 columns by 4 rows. Shuffle Deck will randomly shuffle all cards in the deck. Play Fibo Solitaire will play the game as described above. Win Fibo Solitaire will automatically continue to play until the person wins and also keep track of how many games were play to get the win Exit will exit the program

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

What are the advantages of Internet EDI over traditional EDI?

Answered: 1 week ago