Question: Part A . [ 4 mark ] Initializing a Sequence of Cards Your first task is to write a program that can initialize a sequence

Part A.[4 mark] Initializing a Sequence of Cards
Your first task is to write a program that can initialize a sequence of cards, which is used for playing the simple UNO game. The program takes one integer from the user and it is the seed for the card sequence generation. As shown in the following Table1, the value of seed is from 1 to 20, and each seed corresponds to one specific sequence. Then it prints the entire sequence of cards. We provide a skeleton of code in the file asg3_skeleton_partA.cpp, and you need to complete the program.
Now to begin, a card has three attributes: color, value and number. There are 4 colors with their corresponding values: Red with value 1, Yellow with value 2, Blue with value 3 and Green with value 4. There are 9 numbers: the integers from 1 to 9. A card is combined with one color and one number randomly, such as Red3, Yellow3, Blue7 and Green 1.
A class called Card is provided in the skeleton code, with the above attributes defined as private members. Color is a pointer to char, i.e., char*, or equivalently cstrings. Some access function prototypes are also defined. There is also a prototype of the default constructor. You need to implement these access functions and the default constructor in order to complete the class definition of Card.
To initialize a sequence of cards, you need to implement one function. A sequence is simply an array of Card objects as you can see in main(). The initSequence(Card* cardSeq, char colorName[][10], int*\( j \), int* num) is the function to initialize the sequence of cards. For one sequence, there are 6 cards. When you create each card, you should first set its value and its color according to the value as shown in Table1. Then, combining the color with the number, you can get a card. Note that the sequence is passed to the function as a pointer (Card *), and you should not change this.
We provide a help function called printSequence which simply takes the sequence (again as a pointer) and prints each Card object sequentially. This is called in main() to check output of your code. Notes:
1. Based on skeleton code, complete the class definition of Card.
2. You are not allowed to delete any part of the skeleton code.
3. Do not add / move attributes or member functions.
4. Finish all the default constructor or functions.
5. Table1 is shown below.
Sample Input and Output
Example 1
Enter the seed for random number generation: 1
Yellow9 Blue5 Yellow2 Blue1 Blue3 Yellow3
Example 2
Maresen Vioul Shode Dutug Censole
Enter the seed for random number generation: 10
Green7 Red6 Yellow9 Blue7 Bluel Blue3
Example 3
Enter the seed for random number generation: 6
Blue5 Green5 Blue7 Red8 Red6 Blue7```
#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();
private:
char* color;
int value;
int number;
};
// 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);
int main(){
// Add your code here.
initSequence(cardSeq, colorName, j, num);
printSequence(cardSeq);
}
return 0;
// Add your code here.
// You need to implement initSequence(Card* cardSeq, char colorName[][10], int* j,
int* num) function.
// Add your code here.
// You need to implement printSequence(Card* cardSeq) function.
```
Part A . [ 4 mark ] Initializing a Sequence of

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!