Question: Part B . [ 4 marks ] Playing the Simple UNO Game Extend your program in Part A , so it can play the simple
Part B 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 asgskeletonpartB.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 Red Green Green Yellow Green Blue 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 to and the other is the number from to 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: There is no suitable card for you to play and you lose. There is no suitable card for the computer to play and you win. 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.
Refer to the Notes of Part A
You may add new member functions to Card and new nonmember functions to the program.
If there is no suitable card for you to play, please input 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.
Sample Input and Output
Example
Enter the seed for random number generation:
Your card sequence: Yellow Blue Yellow Bluel Blue Yellow
Computer's card sequence: Red Green Green Yellow Green Blue
The computer plays Red please input two integers to represent the card you plan to play: Game continues. Your remaining cards: Yellow Blue Yellow Blue Yellow
The computer plays Blue please input two integers to represent the card you plan to play: Game ends. you lose
Example
Enter the seed for random number generation:
Your card sequence: Red Yellow Red Blue Blue Green
Computer's card sequence: Red Green Green Yellow Green Blue
The computer plays Red please input two integers to represent the card you plan to play: Game continues. Your remaining cards: Yellow Red Blue Blue Green
The computer plays Blue please input two integers to represent the card you plan to play: Game ends. You win
Example
Enter the seed for random number generation:
Your card sequence: Red Blue Green Blue Yellow Yellow
Computer's card sequence: Red Green Green Yellow Green Blue
The computer plays Red please input two integers to represent the card you plan to play: Game ends. You win
Example
Enter the seed for random number generation:
Your card sequence: Yellow Red Red Green Yellow Blue
Computer's card sequence: Red Green Green Yellow Green Blue
The computer plays Red please input two integers to represent the card you plan to play: Game cont inues. Your remaining cards: Yellow Red Green Yellow Blue
The computer plays Green please input two integers to represent the card you plan to play: Game continues. Your remaining cards: Yellow Red Yellow Blue
The computer plays Green please input two integers to represent the card you plan to play: Game ends. you lose
#include
#include
using namespace std;
class Card
public:
Card;
void setColorchar n;
void setValueint v;
void setNumint 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:
Based on skeleton code, complete
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
