Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help writing this program c++ Solitaire is a card game that is played by one person. Solitaire is also known by the name
I need help writing this program c++
Solitaire is a card game that is played by one person. Solitaire is also known by the name "Patience". It is estimated that there are more than 1700 different versions of Solitaire... make that 1701 because we are inventing a new Solitaire game today. Welcome to Solitaire Prime! 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 prime number, discard that pile (hand), and start over at instruction #1 4) If the Sum is not prime, take the next card from the top of the deck and place it on top of the card stack (pile or hand) on the table. 5) The Sum is now the sum of all cards in the stack on the table. 6) Go to instruction #3. Continue to play the game, keeping track of how many piles you have created that are prime. If the last card from the deck gives you a prime pile, then you win! Write the word "Winner" on the screen and show how many prime piles there were. If the last card from the deck does not give you a prime pile, then you lose. Write the word "Loser" in the screen. CHUserstveng Documents Visual These 2 screen shots show possible winner and loser hands. When you Playing Solitaire Print! acquire a Prime pile, print out the N. 90. Prin:17 20. Prine 2 10.1. A. Prine13 value (prime number) and start over C. 2. Prine17 18. 9H. Prine 113 "on the next line. 2. Prime: 20. Prin!? iRs. 10. Prine: 17 TS. 30. Prin:13 I. Prime ns. 20. Prime: 3. c. 7. Prin 117 c. 60. C. ks. 90. 21. 58. Prinet? H. 98. Prine 27 BH. JD. 6C, AC. Priner23 3. Print3 2. Prime 8. SC. SD, SD. Prin 131 You will have 2 classes: D. 35. 100. SC. Frie19 18, 69, 180, MD, QH, 108, Loser 1) The Deck class which will create the deck of cards 2) The Card class which CiUsersteung SPOR creates cards Playing Solitaire Pr!! 2. $. 5. 6. 4. Prime:23 The main logic of the . Pri 17 17 24. Prine 17 C.S. Prine 117 UD. 3D. Fri 113 4H.D. Prime:19 3HPrin 13 2. SC. QC. ss. 28. 8. 10. 10. 2. Pie73 20. Prin 20. Trinn 12 SC. 30. Prime:19 SC. Prints 15. 18. 95. Prime=23 3H Prines N. 25. 08. Je. Ac. Pri 121 20. Prise 17 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. Feel free to . c. 4. 185. K. K. .. . . Prie: add more if you need them. Minder in 18 pleet 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 refreshDeck(); // 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 int cards Left() // return the number of cards left in the deck public void showDeck(); // show all the cards in the deck: 13 columns and 4 rows. public class Card public Card() // create a "blank" card public Card char r, chars) // constructor to create a card, setting the rank and suit public void setCard char r, char s) // set an existing blank card to a particular value public int getValue() // return the point value of the card. Ace= 1, 2 thru 10, Jack = 10, Queen= 10, King = 10 public void showCard() // display the card using 2 fields... Ace of Spade:AS, Ten of Diamond: 10D, Queen of Heart:QH, Three of Club:30. (If you want to get fancy, you can use these symbols for the suit , In the main function, you will have a menu that looks like this: Welcome to Solitaire Prime! 1) New Deck 2) Display Deck 3) Shuffle Deck 4) Play Solitaire Prime 5) Exit New Deck will create an unshuffled deck in the following order: Spades, Hearts, Diamonds, Clubs... Ace, 2, 3, ..., 10, Jack, Queen, King Disnlay Decl will disnlay all cards in aarid: 13 columns by 4 w (If you want to get fancy, you can use these symbols for the suit In the main function, you will have a menu that looks like this: Welcome to Solitaire Prime! 1) New Deck 2) Display Deck 3) Shuffle Deck 4) Play Solitaire Prime 5) Exit 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 Solitaire will play the game as described above. 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 "isPrime (cannot use any C++ library function). One is NOT a prime number Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started