Question In this homework you will be making 1 base class a
 Question: In this homework you will be making 1 base class a...
 Bookmark
 In this homework you will be making 1 base class and 2 derived classes.
Base Class: Character -- have hit points
Derived 1: Monster - high damage, low damage, xp value
Derived 2: Non Player - talkative (true false)
For all variables, have set, get and display functions.
You will be submitting 7 files
Monster.h and cpp
Non Player h.cpp
Character.h and cpp
main.cpp
Remember to use the preprocessor trick on the header files
Main should create an object of each class, make sure the variables are initialized and call display.
Also, make a UML class inheritance diagram, showing what you made.
Solution
#include<iostrem>
using namespace std;
// Base class Shape
class Shape {
public:
void setwidth(int w ) {
width = w;
}
void setHeight(int h) {
height =h;
}
protected:
int width;
int height;
};
//Base class PaintCost
class PaintCost {
public:
int getCost(int area) {
return area * 70;
}
};
//Derived class
class Rectangle: public Shape, public PaintCost {
public:
int getArea() {
return (width * height);
}
};
int main(void){
Rectangle Rect;
int area;
Rect.setWidth(5);
Rect.setHeight(7);
area = Rect.getArea();
// print the area of the object.
cout << \"Totle area:\"<<Rect.getarea()<<endl;
//print the total cost of painting
cout <<\"Total paint cost:$\" <<Rrct.getarea() <<endl;
return 0;
}


