Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions

Question

=+3. How do you want to affect this reputation?

Answered: 1 week ago

Question

what is max unsigned integer for 2 bit in c

Answered: 1 week ago