I need your help! I got most of the coding for my assignment, but I need to add two more methods I believe.. Can you PLEASE look at the requirements and compare it to what I have and tell me what I'm missing and help me finish it. Also, put comments on the each line telling me what it means. I would greatly appreciate it. I've been watching your videos and trying to teach myself for this advance c++ class because our last professor didn't teach as at all.
REQUIREMENTS:
Create a new base class called Human with two new classes
that inherit the human class called Elf and Ranger.
Those two classes must use a method that belongs to the Human class (attack). They must also have their own methods (at least two).
Those two methods could assign the HP or strength of the elf or ranger while the attack needs to be inherited from the Human class.
WHAT I HAVE SO FAR:
#include <iostream>
#include <string>
using namespace std;
// Base class
class Human
{
public:
// pure virtual function providing interface framework.
virtual int attack(string weapon) = 0;
void setWeapon(int w)
{
weapon = w;
}
protected:
int weapon;
};
// Derived classes
class Elf : public Human
{
public:
int attack(string weapon, int enemyHP)
{
if (weapon == "dagger")
{
strength = 500;
}
return strength;
}
int hp = 0;
int strength = 0;
};
class Ranger : public Human
{
public:
int attack(string weapon, int enemyHP)
{
if (weapon == "bow")
{
strength = 700;
//abstract method to be used in inherited class
virtual int attack(string weapon, int enemyHP) = 0;
//method to set the characters health
void setHealth(int health)
{
inthealth = health;
}
//method to get the characters health
int getHealth()
{
return(intHealth);
}
//method to set the characters strength
void setStrength(int strength)
{
intStrength = strength;
}
//method to get the characters strength
int getStrength()
{
return(intStrength);
}
//new method to pass in a weapon
void setWeapon(string weaponName)
{
weapon = weaponName;
}
//new method to get the weapon being used
string getWeapon(string weaponName)
{
return(weapon);
}
protected:
int intHealth = 0;
int intStrength = 0;
string weapon;
int weaponCondition = 100;
}
// Derived classes
class Elf : public Human
{
public:
int attack(string weapon, int enemyHP)
{
//initial attack
int attackValue = intStrength;
//new attack based on weapon
int additionalAttack = 0;
//if the character is equiped with a dagger then the additional attack added is +500
if (weapon == "dagger")
{
additionalAttack = intStrength + 500;
}
//if the character is equiped with a fists then the additional attack added is +50
if (weapon == "fists")
{
additionalAttack = intStrength + 50;
}
//final attack value based on initial attack + equiped weapon attack
attackValue = attackValue + additionalAttack;
//reduces the enemies health
enemyHP = enemyHP - attackValue;
return(enemyHP);
}
};
class Ranger : public Human
{
public:
int attack(string weapon, int enemyHP)
{
if (weapon == "bow")
{
strength = 700;
if (weapon = "rock")
strength = 100;