Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do not use advanced methods or copy and paste from elsewhere C++ Programing please We are inventing a new Solitaire game today. Welcome to Solitaire

Do not use advanced methods or copy and paste from elsewhere

C++ Programing please

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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 on the screen. These 2 screenshots show possible winner and loser hands. When you acquire a Prime pile, print out the value (prime number) and start over on the next line X Playing Solitaire Prime!!! Playing Solitaire Prime !!! 8H, 9C, Prime :17 2D, Prime : 2 4D, 8S, AH, Prime :13 KC, 78, Prime :17 41, 9H, Prime :13 2H, Prime:7 2C, Prime: 7 10S, 9D, Prime : 19 JS, 3C, Prime :13 5H, Prime : 5 AS, 20, Prime: 3 QC, 7D, Prime :17 3D, Prime: 3 4C, 6D, JC, KS, QD, 2H, 5S, Prime:47 JH, KH, 9S, Prime:29 6H, JD, 6C, AC, Prime : 23 3H, Prime : 3 2S, Prime : 2 QS, 8C, 8D, 5D, Prime : 31 AD, 38, 10D, 5C, Prime : 19 4S, 6S, 10C, KD, QH, 10H, Loser AD, 5D, JS, 6S, AH, Prime : 23 2H, Prime : 9C, 8H, Prime : 17 JD, 3D, Prime :13 2H, Prime : 2 6D, 41, 9D, Prime : 19 3H, Prime: 3 QH, 8C, QC, 8S, 2S, 8D, 10D, 10H, 2s, Prime: 73 7D, Prime: 7 2D, Prime : 2 6C, 3C, KH, Prime : 19 5C, Prime : 5 48, 10, 9s, Prime:23 5H, Prime : 5 6H, 3S, AS, KD, JC, AC, Prime: 31 5S, Prime: 5 7C, Prime: 7 JH, 4C 20 QS, 10C, KS, KC, 4D, QD, 9H, Prime : 79 Winner in 18 piles! TTT TIT HERE ARE THE RULES OF THE CODE - You must create your own function to shuffle (cannot use the random_shuffle provided by C++) - you must create your own function called isPrime (cannot use any C++ library function). One is NOT a prime number. - Use Arrays, Use the rand() function for shuffling cards -Get a random number within a range of numbers - Use a Header File, Protect Header Files using #ifndef, #define, #endif - Do not use anything too advanced such as Stack and Map functions. - Create the required methods and Classes listed below You will have 2 classes: 1) The Deck class which will create the deck of cards 2)The Card class which creates card 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 that are required to create. Feel free to add more if you need them. public class Deck public Deck( ) // constructor that will create 52 card deck. 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 cardsLeft() // 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( charr, chars) // 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:3C. (If you want to get fancy, you can use these symbols for the suit 2, 4, 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

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

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions