Question: Main (.cpp) file (code): #include using namespace std; class Zombie { protected: int cur_x, cur_y; string speed; // slow or fast string type; // freshly

Main (.cpp) file (code):

#include

using namespace std;

class Zombie {

protected:

int cur_x, cur_y;

string speed; // slow or fast

string type; // freshly dead or very dead

int dest_x, dest_y;

public:

// Constructor

Zombie () {

cur_x = cur_y = 0;

speed = "slow"; type = "freshly dead";

}

Zombie(int x, int y) {

cur_x = x; cur_y = y;

speed = "slow"; type = "freshly dead";

}

// takes two integers and makes that the zombies desired location

void setDestination(int xPos, int yPos) {

dest_x = xPos; dest_y = yPos;

}

// movie zombie towards target goal

int takeTurn() {

if (cur_x != dest_x)

cur_x += 1;

if (cur_y != dest_y)

cur_y += 1;

return hit();

}

// print the position and some information

void printInfo() {

cout

cout

cout

}

// returns amount of damage zombie does

int hit() {

if (type == "freshly dead")

return 3;

else

return 0;

}

// getter mehtod for type

string getType() {

return type;

}

// getter method for speed

string getSpeed() {

return speed;

}

};

class Weapon

{

//class attributes

int type;

int range;

int force;

public:

//default constructor

Weapon()

{

type=0;

range=0;

force=0;

cout

}

//Destructor

~Weapon()

{

cout

}

//parameterized constructor

Weapon(int T)

{

//set range and force based on type

type=T;

if(type==1)

{

range=1000;

force=5000;

}

else if(type==2)

{

range=2000;

force=6000;

}

if(type==3)

{

range=3000;

force=7000;

}

cout

}

//setters

void setRange(int newRange)

{

range=newRange;

cout

}

void setForce(int newForce)

{

force=newForce;

cout

}

void setType(int newType)

{

type=newType;

cout

}

//getters

int getRange()

{

return range;

cout

}

int getForce()

{

return force;

cout

}

int getType()

{

return type;

cout

}

};

//Driver Code

int main()

{

// sample test class

Zombie z;

z.setDestination(3, 4);

int damage = z.takeTurn();

cout

Weapon W1; //uses default constructor

Weapon W2(2);//uses parametrized constructor

//displaying the values of W1

cout

cout

cout

//displaying the values of W2

cout

cout

cout

//updating values for W1

W1.setRange(10000);

W1.setForce(15000);

W1.setType(1);

//updating values for W2

W2.setRange(20000);

W2.setForce(25000);

W2.setType(3);

//displaying the updated values of W1

cout

cout

cout

//displaying the updated values of W2

cout

cout

cout

return 0;

}

INSTRUCTIONS:

Main (.cpp) file (code): #include using namespace std; class Zombie {protected: int

Super Zombies OK. Now on to something we hinted at last week: make all zombies have speed 3. Next, make a new class Zombie28 (from the fast-moving zombies in 28 days later) that extends Zombie. In other words, Zombie28 is a child class of Zombie. What do you need to modify to make that happen? Perhaps the constructors? The major difference between a Zombie and a Zombie28 is movement speed but you can make other changes like giving it more health or only making it weak to a shotgun. It would also be a good idea to have a printinfo function for Zombie and Zombie28 classes. That way it's easy to indicate where each Zombie is. Your Zombie28 class should also have a setDestination, hit, and takeTurn functions plus getter methods like the Zombie class

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!