Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++. No copying from other code, only use the methods and functions allowed in the instructions. NO stack, printreversestack, or other methods allowed. Welcome

In C++. No copying from other code, only use the methods and functions allowed in the instructions. NO stack, printreversestack, or other methods allowed.image text in transcribedimage text in transcribedimage text in transcribed

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: Winning Game: (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 ,,4, In the main function, you will have a menu that looks like this: Welcome to Fibonacci Solitaire! 1) Create New Deck 2) Shuffle Deck 3) Display Deck 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. You must create your own function to shuffle (cannot use the random_shuffle provided by C++ ) and you must create your own function called isFibo(int) You must use array to store your cards in Deck. You cannot use vector for this assignment

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

What would you do if the bullies and victim were girls?

Answered: 1 week ago