Question: To use an array. 2. To use functions from the math library. 3. To implement some simple logic. 4. To use C++ input and output.
To use an array. 2. To use functions from the math library. 3. To implement some simple logic. 4. To use C++ input and output. 5. To read single characters or numbers or stings from the keyboard We will build a program where your wish will be granted if you can guess the card chosen by the genie. The game will choose a card at random and you have to guess which one it is. If you choose correctly, your wish is granted! 2 Requirements Create a program in C++ for a game that picks a cards suit and value at random and the player has to guess the card and suit. You must follow the following requirements. 1. Create an array with 4 slots for the suits hearts, diamonds, clubs and spades. The slots can contain an integer showing the suits number (easier, cannot earn an A or A+) or a string showing the name. 2. Create another array with 13 slots (one per card value 2 to ace). The slots can contain an integer showing the cards value 1 to 13 (easier, cannot earn an A or A+) or a string showing the name (two to ace). 3. Use the rand() function twice to randomly select the index of the card and suit. You can show these on the screen when you are testing, but comment out the print when you submit your program. Include a comment identifying the line so I can use it to test. 4. Welcome your user to the game and explain what the game is. Ask them to play the game to have one wish granted by the Genie 5. Print a menu for the user to choose the suit from. The menu must use the array of suits. Use a for loop to go through the suits array. a. Then ask the user to enter a number/letter/word to guess the cards suit. The last item on the menu should be an option to quit. Read the input using the correct function to read keyboard input in C++. b. Use a loop to check that the user entered a valid choice (validate entry), if the entry is invalid: i. Tell them it is invalid, ii. show the options they can choose from, the last choice should be to quit iii. and ask them to try again. c. If the user quits, the program should end with a message thanking them for using the program. d. If the user does not guess the correct suit, the program should tell them it is wrong and invite them to try again. The program should end with an appropriate message. 6. If the user correctly selects the secret suit: a. Show the menu of cards to choose from and ask them to guess the value of the card. b. Use the array of cards and a for loop to display the menu. The last item should be the option to quit. c. Read the input using the correct function to read keyboard input in C++. CSCI 2212 Intermediate Programming C++ Spring 2019 Program 3 Requirements Get Your Wish d. Use a loop to check that the user entered a valid choice (validate entry), if the entry is invalid: i. Tell them it is invalid, ii. show the options they can choose from, the last choice should be to quit iii. and ask them to try again. e. If the user quits, the program should end with a message thanking them for using the program. f. The program should show the suit and card selected by the user on one line. g. If the user does not guess the correct card, the program should tell them it is wrong and invite them to try again. The program should end with an appropriate message. h. If the user guesses correctly, the program should congratulate them for winning. Then the program should end with a message thanking them for using the program. 7. When the user enters values that are invalid (suit is not a suit, card is not a card) make sure the handling is graceful. The program should give an error message and allow them to try again. Style Guide Follow the instructions in the style guide fully. There are deductions for style. Testing and Output. Test your program with at least 5-6 tries, include one to three correct guesses, try correct suit but wrong card, try both wrong, and a few with invalid choices or other errors. You can print the secret card selected to the screen so you can guess as needed for the tests. Test that when the user enters values that are invalid that the exit is graceful. E.g. program should not crash. Message is shown and program is able to continue or end gracefully. Challenges do any subset or all of these for extra credit, 1 point each: 1. Use a file for the input data for the cards and the suits. 2. Output the resulting dialog to a file. 3. Put a recognizable character-based image on the console for the card showing a card shape with the suit as a shape and the value. You must build the image from ASCII or UTF-8 characters.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
