Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Section B Play a simple UNO game use only and Expand your program in Section A so that it can play simple UNO games with

Section B Play a simple UNO game

use only and

Expand your program in Section A so that it can play simple UNO games with you as the sole player. We provide a skeleton cod that you need to complete the program.

The game is as follows. First, the program asks the user to enter a seed generated by the card sequence. It initializes your card sequence, just like the basic level. Then the game began.

In the first round, the default function in the skeleton code calls the function you designed in Part A and initializes according to the computer's specific card sequence ([Red1 Green9 Green4 Yellow3 Green3 Blue5]). The computer then displays the first card in order.

In the second round, the program will ask you to enter two integers to represent your cards: a number from 1 to 4, and a number from 1 to 9. But your input has three rules. First, the cards you play must be in the sequence of cards generated before the game starts. Second, this card will be removed from the sequence after you finish playing. Third, you must play the same color or number of cards as you played in the previous round on the computer. After you play this card, the program prints the rest of your card sequence.

In the third round, the computer will play a card that follows the same three rules. First, the cards played by the computer must match the order it generated in the first round. Second, the card will be removed from the computer's card sequence after the computer plays it. Third, the computer must play the same color or number of cards you played in the previous round. You should design logic code for the computer to help it do this: the computer should choose the first appropriate card in its card sequence as its strategy.

The process for round 4 will be the same as for round 2.

The process for round 5 will be the same as for round 3.

The game ends if one of the following conditions is met:

(1) Without proper cards to play, you lose.

(2) The computer doesn't have the right card, you win.

(3) All cards (yours and the computer's) are played properly and draw.

Some examples of the game in action are shown below. Note that your program output should be exactly the same as the sample output below, using the same seed.

You may add new member functions to Card and new non-member functions to the program. If there is no suitable card for you to play, please input 0 0 and then the game will end. If there are some suitable cards for you to play, but you do not play any one of them, you will lose.

image text in transcribedimage text in transcribed

Section A:

https://www.chegg.com/homework-help/questions-and-answers/write-c-program-perform-simple-uno-game-kind-card-game-following-encoding-scheme-use-libra-q88732739?trackid=sTaMUs4C

Section B skeleton code:

#include #include using namespace std; class Card { public: Card(); void setColor(char* n); void setValue(int v); void setNum(int num); char* getColor(); int getVal(); int getNum(); // Add your code here. private: char* color; int value; int number; // Add your code here. }; // Add your code here. // You need to implement these access functions and the default constructor in order to complete the class definition of Card. void initSequence(Card* cardSeq, char colorName[][10], int* j, int* num); void printSequence(Card* cardSeq); // Add your code here. int main() { // Add your code here. initSequence(cardSeq, colorName, j, num); cout Card Sequence Seed NO. 1 Yellow9 Blue5 Yellow2 Blue1 Blue3 Yellow3 2 Yellow3 Blue3 Red4 Blue 8 Yellow2 Yellow2 3 Red6 Blue2 Green7 Blue5 Yellow1 Yellow1 4 Green9 Green9 Yellowl Green3 Red Yellow9 5 Blue2 Green6 Red Greeni Red7 Blue 8 6 Blue5 Green5 Blue7 Red8 Red6 Blue 7 7 Yellow Green3 Yellowl Red5 Green5 Blue 6 8 Redi Green 9 Green4 Yellow3 Green3 Blue5 9 Red5 Green7 Blue 6 Yellowl Blue2 Blue 4 10 Green7 Red Yellow Blue7 Bluel Blue3 11 Bluel Red4 Green3 Blue5 Blue8 Blue2 12 Yellow4 Redl Blue 6 Green2 Yellow7 Blue1 13 Yellowo Red Red Green9 Yellow Blue 9 14 Red9 Red7 Green3 Green6 Red5 Blue 8 15 Green3 Red5 Yellow6 Red4 Red4 Green7 16 Blue 6 Yellow3 Red9 Red2 Green2 Green6 17 Blue 8 Yellowl Green2 Yellow Greenl Green5 18 Yellow2 Yellow Yellow5 Yellow Green 9 Green4 19 Red5 Yellow7 Red8 Blue 4 Blue 8 Green3 20 Green7 Yellow4 Bluel Blue2 Blue7 Green2 Enter the seed for random number generation: 19 Your card sequence: Red5 Yellow7 Red8 Blue4 Blue8 Green3 Computer's card sequence: Redl Greeng Green4 Yellow3 Green3 Blue5 The computer plays Redl, please input two integers to represent the card you plan to play: 15 Game continues. Your remaining card(s): Yellow7 Red8 Blue4 Blue Green3 The computer plays Blue5, please input two integers to represent the card you plan to play: 3 8 Game ends. You win C:\Users\jli242\source reposlasg3\Debug asg3.exe (process 3596) exited with code 0. Press any key to close this window Microsoft Visual Studio Debug Console Enter the seed for random number generation: 3 Your card sequence: Red6 Blue2 Green7 Blue5 Yellowl Yellowl Computer's card sequence: Redl Green9 Green4 Yellow3 Green3 Blue5 The computer plays Redl, please input two integers to represent the card you plan to play: 1 6 Game ends. You win C:\Users\jli242\source repos asg3\Debug\asg3.exe (process 16420) exited with code 0. Press any key to close this window. .. Microsoft Visual Studio Debug Console Enter the seed for random number generation: 13 Your card sequence: Yellow6 Red9 Red8 Green9 Yellow6 Blue9 Computer's card sequence: Redl Greeng Green4 Yellow3 Green3 Blue5 The computer plays Redl, please input two integers to represent the card you plan to play: 1 9 Game continues. Your remaining card(s): Yellow6 Red Greeng Yellow6 Blue9 The computer plays Green9, please input two integers to represent the card you plan to play: 49 Game continues. Your remaining card(s): Yellow6 Red8 Yellow6 Blue9 The computer plays Green4, please input two integers to represent the card you plan to play: 0 0 Game ends. you lose Card Sequence Seed NO. 1 Yellow9 Blue5 Yellow2 Blue1 Blue3 Yellow3 2 Yellow3 Blue3 Red4 Blue 8 Yellow2 Yellow2 3 Red6 Blue2 Green7 Blue5 Yellow1 Yellow1 4 Green9 Green9 Yellowl Green3 Red Yellow9 5 Blue2 Green6 Red Greeni Red7 Blue 8 6 Blue5 Green5 Blue7 Red8 Red6 Blue 7 7 Yellow Green3 Yellowl Red5 Green5 Blue 6 8 Redi Green 9 Green4 Yellow3 Green3 Blue5 9 Red5 Green7 Blue 6 Yellowl Blue2 Blue 4 10 Green7 Red Yellow Blue7 Bluel Blue3 11 Bluel Red4 Green3 Blue5 Blue8 Blue2 12 Yellow4 Redl Blue 6 Green2 Yellow7 Blue1 13 Yellowo Red Red Green9 Yellow Blue 9 14 Red9 Red7 Green3 Green6 Red5 Blue 8 15 Green3 Red5 Yellow6 Red4 Red4 Green7 16 Blue 6 Yellow3 Red9 Red2 Green2 Green6 17 Blue 8 Yellowl Green2 Yellow Greenl Green5 18 Yellow2 Yellow Yellow5 Yellow Green 9 Green4 19 Red5 Yellow7 Red8 Blue 4 Blue 8 Green3 20 Green7 Yellow4 Bluel Blue2 Blue7 Green2 Enter the seed for random number generation: 19 Your card sequence: Red5 Yellow7 Red8 Blue4 Blue8 Green3 Computer's card sequence: Redl Greeng Green4 Yellow3 Green3 Blue5 The computer plays Redl, please input two integers to represent the card you plan to play: 15 Game continues. Your remaining card(s): Yellow7 Red8 Blue4 Blue Green3 The computer plays Blue5, please input two integers to represent the card you plan to play: 3 8 Game ends. You win C:\Users\jli242\source reposlasg3\Debug asg3.exe (process 3596) exited with code 0. Press any key to close this window Microsoft Visual Studio Debug Console Enter the seed for random number generation: 3 Your card sequence: Red6 Blue2 Green7 Blue5 Yellowl Yellowl Computer's card sequence: Redl Green9 Green4 Yellow3 Green3 Blue5 The computer plays Redl, please input two integers to represent the card you plan to play: 1 6 Game ends. You win C:\Users\jli242\source repos asg3\Debug\asg3.exe (process 16420) exited with code 0. Press any key to close this window. .. Microsoft Visual Studio Debug Console Enter the seed for random number generation: 13 Your card sequence: Yellow6 Red9 Red8 Green9 Yellow6 Blue9 Computer's card sequence: Redl Greeng Green4 Yellow3 Green3 Blue5 The computer plays Redl, please input two integers to represent the card you plan to play: 1 9 Game continues. Your remaining card(s): Yellow6 Red Greeng Yellow6 Blue9 The computer plays Green9, please input two integers to represent the card you plan to play: 49 Game continues. Your remaining card(s): Yellow6 Red8 Yellow6 Blue9 The computer plays Green4, please input two integers to represent the card you plan to play: 0 0 Game ends. you lose

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

More Books

Students also viewed these Accounting questions

Question

CL I P COL Astro- L(1-cas0) Lsing *A=2 L sin(0/2)

Answered: 1 week ago

Question

Why has Negotiating Women, Inc. focused its attention on women?

Answered: 1 week ago