Hello I need help please to create a function that will return the distance between the invoking Character object and a parameter Character object as the total of steps it would take from one object to the other. For example, · The distance between a character at (0, 0) and another character at (1, 2) would be 3. · The distance between a character at (0, 0) and another character at (2, 1) would be 3. · The distance between a character at (2, 1) and another character at (1, 2) would be 2.
Hello I need help please to create a function that will return the distance between the invoking Character object and a parameter Character object as the total of steps it would take from one object to the other. For example,
· The distance between a character at (0, 0) and another character at (1, 2) would be 3.
· The distance between a character at (0, 0) and another character at (2, 1) would be 3.
· The distance between a character at (2, 1) and another character at (1, 2) would be 2.
Using this character class:
#ifndef CHARACTER_H
#define CHARACTER_H
class Character {
private:
static unsigned max_x;
static unsigned max_y;
unsigned x_, y_; //where the character is located
public:
static void setLimits(unsigned w, unsigned h);
Character();
Character(unsigned x, unsigned y);
//to return the coordinates of location_
std::string to_string() const;
//mutators
void setLocation(unsigned x, unsigned y);
void moveLeft();
void moveRight();
void moveUp();
void moveDown();
};
#endif


Step by step
Solved in 4 steps with 4 images









