1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
#include <iostream>
#include <string>
class Character
{
public:
Character
(
const std::string& name_in,
const std::string& race_in,
const std::string& gender_in,
double health_in,
double magicka_in,
double carryWeight_in,
double stamina_in,
const std::string& ability_in
);
Character();
Character(const std::string& defaultName, const std::string& defaultRace);
std::string GetName() const { return name; }
void SetName(const std::string& name_) { name = name_; }
std::string GetRace() const { return race; }
std::string GetGender() const { return gender; }
std::string GetAbility() const { return ability; }
double GetHealth() const { return health; }
double GetMagicka() const { return magicka; }
double GetCarryWeight() const { return carryWeight; }
double GetStamina() const { return stamina; }
void Speak(const std::string& dialogue)
{
std::cout << GetName() << ": " << dialogue << std::endl;
}
private:
std::string name{ "NPC" };
std::string race{ "Unknown" };
std::string gender{ "Unknown" };
double health{ 100 };
double magicka{ 100 };
double carryWeight{ 150 };
double stamina{ 100 };
std::string dialogue{};
std::string ability{ "None" };
};
//This will allow me to create a character by entering all the values in myself.
Character::Character
(
const std::string& name_in,
const std::string& race_in,
const std::string& gender_in,
double health_in,
double magicka_in,
double carryWeight_in,
double stamina_in,
const std::string& ability_in
): name(name_in),
race(race_in),
gender(gender_in),
health(health_in),
magicka(magicka_in),
carryWeight(carryWeight_in),
stamina(stamina_in),
ability(ability_in)
{
}
//And this will create a default one.
Character::Character() {}
Character::Character(const std::string& name_in, const std::string& race_in) : name(name_in), race(race_in) {}
class Dragon : public Character
{
public:
Dragon
(
const std::string& name_in,
const std::string& race_in,
const std::string& gender_in,
double health_in,
double magicka_in,
double carryWeight_in,
double stamina_in,
const std::string& ability
);
Dragon() : Character("Dragon", "Dragon") {};
private:
std::string ability{ "Shout" };
};
Dragon::Dragon
(
const std::string& name_in,
const std::string& race_in,
const std::string& gender_in,
double health_in,
double magicka_in,
double carryWeight_in,
double stamina_in,
const std::string& ability_in
): Character(
name_in,
race_in,
gender_in,
health_in,
magicka_in,
carryWeight_in,
stamina_in,
ability_in
)
{}
class Nord : public Character
{
public:
Nord
(
const std::string& name_in,
const std::string& race_in,
const std::string& gender_in,
double health_in,
double magicka_in,
double carryWeight_in,
double stamina_in,
const std::string& ability
);
Nord() : Character("Nord", "Nord") {};
private:
std::string ability{ "Cold Resistance" };
};
Nord::Nord
(
const std::string& name_in,
const std::string& race_in,
const std::string& gender_in,
double health_in,
double magicka_in,
double carryWeight_in,
double stamina_in,
const std::string& ability_in
): Character(
name_in,
race_in,
gender_in,
health_in,
magicka_in,
carryWeight_in,
stamina_in,
ability_in
)
{}
void DisplayCharacterInfo(Character& character)
{
std::cout << "Name: " << character.GetName() << std::endl;
std::cout << "Race: " << character.GetRace() << std::endl;
std::cout << "Gender: " << character.GetGender() << std::endl;
std::cout << "Health: " << character.GetHealth() << std::endl;
std::cout << "Magicka: " << character.GetMagicka() << std::endl;
std::cout << "Carry Weight: " << character.GetCarryWeight() << std::endl;
std::cout << "Stamina: " << character.GetStamina() << std::endl;
std::cout << "Ability: " << character.GetAbility() << std::endl;
}
int main()
{
Dragon Alduin("Alduin", "Dragon", "Male", 2355, 50, 150, 80, "Shout");
std::cout << "\n" << std::endl;
Alduin.Speak("Sahloknir, ziil gro dovah ulse! Slen Tiid Vo");
DisplayCharacterInfo(Alduin);
Nord Ysgramor;
std::cout << "\n" << std::endl;
Ysgramor.Speak("Remember this always, son of the north, a Nord is judged not by the manner in which he lived, but the manner in which he died.");
DisplayCharacterInfo(Ysgramor);
return 0;
}
|