Question: Part B . [ 4 marks ] Playing the Simple UNO Game Extend your program in Part A , so it can play the simple

Part B.[4 marks] Playing the Simple UNO Game
Extend your program in Part A, so it can play the simple UNO game with you as the only player. We provide a skeleton of code in the file asg3_skeleton_partB.cpp, and you need to complete the program.
The game is follows. At first, the program asks the user to input the seed for the card sequence generation. It initializes a sequence of cards which are your cards, just like the basic level. Then the game starts.
In the first round, the default function in skeleton code will call the function you designed in part A and initialize following specific sequence of cards for computer ([Red1 Green9 Green4 Yellow3 Green3 Blue5]). Then the computer will show you the first card in its sequence.
In the second round, the program will ask you to enter two integers to represent the card you play: one is the value from 1 to 4 and the other is the number from 1 to 9. But there are three rules for your input. First, the card you play must within the card sequence you generated before the game starts. Second, this card will be removed from the sequence after you play it. Third, the card you play must be either the same color or number as the computer played in the last round. After you play the card, the program will print your remaining card sequence.
In the third round, the computer will play a card which also follows the three rules mentioned above. First, the card that computer plays must within the card sequence it generated at the first round. Second, this card will be removed from the computer's card sequence after the computer plays it. Third, the card that the computer plays must be either the same color or number as you played in the last round. You should design the logic code for computer to help it achieve this step: the computer should choose the first suitable card in its card sequence as its strategy.
In the fourth round, the process will be the same as the second round.
In the fifth round, the process will be the same as the third round.
The game will end if one of these conditions are met: (1) There is no suitable card for you to play and you lose. (2) There is no suitable card for the computer to play and you win. (3) All the cards (yours and the computer' s) are suitably played and get a draw.
Some sample runs of the game are shown below. Note your program output should be exactly the same as the sample output below, using the same seed.
1. Refer to the Notes of Part A.
2. You may add new member functions to Card and new non-member functions to the program.
3. If there is no suitable card for you to play, please input 00 and then the game will end.
4. If there are some suitable cards for you to play, but you do not play any one of them, you will lose.
Sample Input and Output
Example 1
Enter the seed for random number generation: 1
Your card sequence: Yellow9 Blue5 Yellow2 Bluel Blue3 Yellow3
Computer's card sequence: Red1 Green9 Green4 Yellow3 Green3 Blue5
The computer plays Red1, please input two integers to represent the card you plan to play: 31 Game continues. Your remaining card(s): Yellow9 Blue5 Yellow2 Blue3 Yellow3
The computer plays Blue5, please input two integers to represent the card you plan to play: 29 Game ends. you lose
Example 2
Enter the seed for random number generation: 19
Your card sequence: Red5 Yellow7 Red8 Blue4 Blue8 Green3
Computer's card sequence: Red1 Green9 Green4 Yellow3 Green3 Blue5
The computer plays Red1, please input two integers to represent the card you plan to play: 15 Game continues. Your remaining card(s): Yellow7 Red8 Blue4 Blue8 Green3
The computer plays Blue5, please input two integers to represent the card you plan to play: 38 Game ends. You win
Example 3
Enter the seed for random number generation: 3
Your card sequence: Red6 Blue2 Green7 Blue5 Yellow1 Yellow1
Computer's card sequence: Red1 Green9 Green4 Yellow3 Green3 Blue5
The computer plays Red1, please input two integers to represent the card you plan to play: 16 Game ends. You win
Example 4
Enter the seed for random number generation: 13
Your card sequence: Yellow6 Red9 Red8 Green9 Yellow6 Blue9
Computer's card sequence: Red1 Green9 Green4 Yellow3 Green3 Blue5
The computer plays Red1, please input two integers to represent the card you plan to play: 19 Game cont inues. Your remaining card(s): Yellow6 Red8 Green9 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: 00 Game ends. you lose ```
#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 functio Notes:
1. Based on skeleton code, complete
Part B . [ 4 marks ] Playing the Simple UNO Game

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!