Question: In C + + Create a Character class - a character that encapsulates the fields: string name; - first name; int life; - life (

In C++ Create a Character class - a character that encapsulates the fields:
string name; - first name;
int life; - life (1-10);
char path[10]; - route, saves the last 10 walking directions (directions t-top, b-bottom, l-left, r-right);
can be supplemented if necessary
and methods:
Character(string, int); - constructor, sets fields name and life;
bool Hit(int); - reduces the character's life by the value of the parameter, returns whether the character is alive;
int GetLife(); - returns the amount of life of the character;
void Go(char); - adds walking direction;
void PrintCharacter(); - outputs the name, alive (then also outputs the number of life points), or dead, the last 10 moves
~Character(); - destructor, outputs the message "Game over for name"
can be supplemented if necessary
Rules:
A character can only be created with life >0
If a character runs out of life, it is considered dead.
Only the PrintCharacter() function works for a dead character, and of course ~Character()
For the Go(char) function, implement the input data correctness check (tblr only).

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 Databases Questions!