Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Character
- {
- protected:
- int constitution;
- int intelligence;
- int health;
- public:
- Character(int c, int i);
- int get_health();
- virtual int get_max_health();
- int get_max_load();
- virtual string class_name() {
- return "Character";
- };
- virtual void display(){
- cout << "Character" << " " ;
- cout << get_health() << endl;
- }
- };
- Character::Character(int c, int i)
- {
- constitution = c;
- intelligence = i;
- health = 10 + constitution;
- }
- int Character::get_health()
- {
- return health;
- }
- int Character::get_max_health()
- {
- return health;
- }
- int Character::get_max_load()
- {
- return (2 * constitution);
- }
- class Wizard:public Character
- {
- protected:
- int spell_level;
- public:
- int get_health();
- int get_max_load();
- int get_max_spell_level();
- virtual int get_max_health();
- virtual string class_name() {
- return "Wizard";
- };
- virtual void display(){
- cout << "Wizard" <<" " ;
- cout << get_health() << endl;
- }
- Wizard(int c, int i);
- };
- Wizard::Wizard(int c, int i) :Wizard::Character(c, i) {
- constitution = c;
- intelligence = i;
- health = 20 + constitution;
- if (intelligence - 10 >= 0)
- spell_level = intelligence - 10;
- else
- spell_level = 0;
- }
- int Wizard::get_health()
- {
- return health;
- }
- int Wizard::get_max_health()
- {
- health = 20 + constitution;
- return (20 + constitution);
- }
- int Wizard::get_max_load()
- {
- return (2 * constitution);
- }
- int Wizard::get_max_spell_level()
- {
- return spell_level;
- }
- class Fighter:public Character
- {
- private:
- int feats;
- public:
- int get_health();
- int get_max_load();
- int get_feats();
- virtual int get_max_health();
- virtual string class_name() {
- return "Fighter";
- };
- virtual void display(){
- cout << "Fighter" <<" ";
- cout << get_health()<<endl;
- }
- Fighter(int c, int i);
- };
- Fighter::Fighter(int c, int i) :Fighter::Character(c, i) {
- constitution = c;
- intelligence = i;
- health = 22 + constitution;
- feats = constitution / 3;
- }
- int Fighter::get_health()
- {
- return health;
- }
- int Fighter::get_max_health()
- {
- return health;
- }
- int Fighter::get_max_load()
- {
- return (3 * constitution);
- }
- int Fighter::get_feats()
- {
- return feats;
- }
- class WizardSpecialist:public Wizard
- {
- private:
- int school;
- int opposed_school;
- public:
- int get_health();
- int get_max_load();
- int get_school();
- int get_opposed_school();
- virtual int get_max_health();
- int get_max_spell_level();
- virtual string class_name() {
- return "WizardSpecialist";
- };
- WizardSpecialist(int c, int i, int d);
- virtual void display(){
- cout << "WizardSpecialist" <<" ";
- cout << get_health() <<endl;
- }
- };
- WizardSpecialist::WizardSpecialist(int c, int i, int d) :WizardSpecialist::Wizard(c, i) {
- constitution = c;
- intelligence = i;
- health = 20 + constitution;
- if (intelligence - 10 >= 0)
- spell_level = intelligence - 10;
- else
- spell_level = 0;
- school = d;
- if (school > 4)
- opposed_school = d - 4;
- else
- opposed_school = d + 4;
- }
- int WizardSpecialist::get_health()
- {
- return health;
- }
- int WizardSpecialist::get_max_health()
- {
- health = 20 + constitution;
- return (20 + constitution);
- }
- int WizardSpecialist::get_max_load()
- {
- return ( constitution / 2);
- }
- int WizardSpecialist::get_max_spell_level()
- {
- return spell_level;
- }
- int WizardSpecialist::get_school(){
- return school;
- }
- int WizardSpecialist::get_opposed_school(){
- return opposed_school;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement