Create a “Boss” class that inherits from the “Armed Enemy” class. Implement an additional
armor level field for the “Boss” class and provide suitable getter and setter methods. Create a
“Boss” Object in the main function to test the functionality of your “Boss” class.
#include <iostream>
class ArmedEnemy{
protected:
float health;
int armor;
public:
ArmedEnemy(float hp = 100, int def = 10){
health = hp;
armor = def;
}
float getHP(){
return health;
}
void setHP(int hp){
health = hp;
}
void setHP(float hp){
health = hp;
}
// add any other methohds you would like to have
};
class Boss:public ArmedEnemy{
private:
float armorShield;
public:
Boss(float hp = 1000, int def = 0, float shield = 100){
health = hp;
armor = def;
armorShield = shield;
}
};
using namespace std;
int main()
{
Boss demon(1000);
demon.setHP(500);
cout<<demon.getHP();
return 0;
}
Comments
Leave a comment