How can I implement the following class definition in c++ You will use a struct called Card to model a single card. This
Posted: Wed Apr 27, 2022 3:48 pm
How can I implement the following class definition in c++
You will use a struct called Card to model a single card. This
struct will contain a data member to store name of the card (of
type string) and another data member to store its energy (of type
int). Card names can only be single words (no spaces in the name;
this is an assumption). If you want, you can write constructor(s)
for this struct, but that is not needed for the main program.
However, you will not write any member functions for this struct.
The deck of cards will be implemented as a class named Deck. In the
Deck class, there should be two private data members: (i) the cards
inside the deck as a dynamic array of Card struct (i.e. Card
pointer); (ii) the size of this dynamic array, i.e. the number of
cards in the Deck object. It is a must to use such a class
structure with a dynamic array of struct in the homework; you
cannot use any other data structure.
You will use a struct called Card to model a single card. This
struct will contain a data member to store name of the card (of
type string) and another data member to store its energy (of type
int). Card names can only be single words (no spaces in the name;
this is an assumption). If you want, you can write constructor(s)
for this struct, but that is not needed for the main program.
However, you will not write any member functions for this struct.
The deck of cards will be implemented as a class named Deck. In the
Deck class, there should be two private data members: (i) the cards
inside the deck as a dynamic array of Card struct (i.e. Card
pointer); (ii) the size of this dynamic array, i.e. the number of
cards in the Deck object. It is a must to use such a class
structure with a dynamic array of struct in the homework; you
cannot use any other data structure.