Suppose you are creating a fantasy role-playing game. In this game we have four different types of Creatures: Humans, Cyberdemons, Balrogs, and elves.    The getDamage() function outputs and returns the damage this Creature can inflict in one round of combat. The rules for determining the damage are as follows: Every Creature inflicts damage that is a random number r, where 0 < r <= strength. Demons have a 25% chance of inflicting a demonic attack which is an additional 50 damage points. Balrogs and Cyberdemons are Demons. With a 50% chance elves inflict a magical attack that doubles the normal amount of damage. Balrogs are very fast, so they get to attack twice Also include mutator and accessor functions for the private variables. Adhere to the following additional requirements: Each of the 6 classes will have exactly 2 constructors. Every class will have a getSpecies() function. We won't be declaring objects of type "Creature" or "Demon", but you should include getSpecies() functions for them anyway, and they should return "Creature" and "Demon", respectively. Make getSpecies() a public member instead of private. Each of the 5 derived classes will have exactly 4 member functions (including constructors) and no data members The Creature class will have 8 member functions (including 2 constructors, 2 accessors, and 2 mutators) and 2 data members.   Here is the client program that you must use to test your classes. int main() {     srand(static_cast(time(nullptr)));          Human h1;     Elf e1;     Cyberdemon c1;     Balrog b1;          Human h(20, 30);     Elf e(40, 50);     Cyberdemon c(60, 70);     Balrog b(80, 90);            cout << "default Human strength/hitpoints: " << h1.getStrength() << "/" << h1.getHitpoints() << endl;     cout << "default Elf strength/hitpoints: " << e1.getStrength() << "/" << e1.getHitpoints() << endl;     cout << "default Cyberdemon strength/hitpoints: " << c1.getStrength() << "/" << c1.getHitpoints() << endl;     cout << "default Balrog strength/hitpoints: " << b1.getStrength() << "/" << b1.getHitpoints() << endl;     cout << "non-default Human strength/hitpoints: " << h.getStrength() << "/" << h.getHitpoints() << endl;     cout << "non-default Elf strength/hitpoints: " << e.getStrength() << "/" << e.getHitpoints() << endl;     cout << "non-default Cyberdemon strength/hitpoints: " << c.getStrength() << "/" << c.getHitpoints() << endl;     cout << "non-default Balrog strength/hitpoints: " << b.getStrength() << "/" << b.getHitpoints() << endl;     cout << endl << endl;       cout << "Examples of " << h.getSpecies() << " damage: " << endl;     for (int i = 0; i < 10; i++){         int damage = h.getDamage();         cout << " Total damage = " << damage << endl;         cout << endl;     }     cout << endl;                    cout << "Examples of " << e.getSpecies() << " damage: " << endl;     for (int i = 0; i < 10; i++){         int damage = e.getDamage();         cout << " Total damage = " << damage << endl;         cout << endl;     }     cout << endl;                    cout << "Examples of " << c.getSpecies() << " damage: " << endl;     for (int i = 0; i < 10; i++){         int damage = c.getDamage();         cout << " Total damage = " << damage << endl;         cout << endl;     }     cout << endl;                    cout << "Examples of " << b.getSpecies() << " damage: " << endl;     for (int i = 0; i < 10; i++){         int damage = b.getDamage();         cout << " Total damage = " << damage << endl;         cout << endl;     }     cout << endl; }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Suppose you are creating a fantasy role-playing game. In this game we have four different types of Creatures: Humans, Cyberdemons, Balrogs, and elves. 

 

The getDamage() function outputs and returns the damage this Creature can inflict in one round of combat. The rules for determining the damage are as follows:

  • Every Creature inflicts damage that is a random number r, where 0 < r <= strength.
  • Demons have a 25% chance of inflicting a demonic attack which is an additional 50 damage points. Balrogs and Cyberdemons are Demons.
  • With a 50% chance elves inflict a magical attack that doubles the normal amount of damage.
  • Balrogs are very fast, so they get to attack twice

Also include mutator and accessor functions for the private variables.

Adhere to the following additional requirements:

  • Each of the 6 classes will have exactly 2 constructors. Every class will have a getSpecies() function. We won't be declaring objects of type "Creature" or "Demon", but you should include getSpecies() functions for them anyway, and they should return "Creature" and "Demon", respectively. Make getSpecies() a public member instead of private.
  • Each of the 5 derived classes will have exactly 4 member functions (including constructors) and no data members
  • The Creature class will have 8 member functions (including 2 constructors, 2 accessors, and 2 mutators) and 2 data members.

 

Here is the client program that you must use to test your classes.

int main() {

    srand(static_cast<unsigned>(time(nullptr)));

    

    Human h1;

    Elf e1;

    Cyberdemon c1;

    Balrog b1;

    

    Human h(20, 30);

    Elf e(40, 50);

    Cyberdemon c(60, 70);

    Balrog b(80, 90);

 

    

    cout << "default Human strength/hitpoints: " << h1.getStrength() << "/" << h1.getHitpoints() << endl;

    cout << "default Elf strength/hitpoints: " << e1.getStrength() << "/" << e1.getHitpoints() << endl;

    cout << "default Cyberdemon strength/hitpoints: " << c1.getStrength() << "/" << c1.getHitpoints() << endl;

    cout << "default Balrog strength/hitpoints: " << b1.getStrength() << "/" << b1.getHitpoints() << endl;

    cout << "non-default Human strength/hitpoints: " << h.getStrength() << "/" << h.getHitpoints() << endl;

    cout << "non-default Elf strength/hitpoints: " << e.getStrength() << "/" << e.getHitpoints() << endl;

    cout << "non-default Cyberdemon strength/hitpoints: " << c.getStrength() << "/" << c.getHitpoints() << endl;

    cout << "non-default Balrog strength/hitpoints: " << b.getStrength() << "/" << b.getHitpoints() << endl;

    cout << endl << endl;

 

    cout << "Examples of " << h.getSpecies() << " damage: " << endl;

    for (int i = 0; i < 10; i++){

        int damage = h.getDamage();

        cout << " Total damage = " << damage << endl;

        cout << endl;

    }

    cout << endl;

    

    

    

    cout << "Examples of " << e.getSpecies() << " damage: " << endl;

    for (int i = 0; i < 10; i++){

        int damage = e.getDamage();

        cout << " Total damage = " << damage << endl;

        cout << endl;

    }

    cout << endl;

    

    

    

    cout << "Examples of " << c.getSpecies() << " damage: " << endl;

    for (int i = 0; i < 10; i++){

        int damage = c.getDamage();

        cout << " Total damage = " << damage << endl;

        cout << endl;

    }

    cout << endl;

    

    

    

    cout << "Examples of " << b.getSpecies() << " damage: " << endl;

    for (int i = 0; i < 10; i++){

        int damage = b.getDamage();

        cout << " Total damage = " << damage << endl;

        cout << endl;

    }

    cout << endl;

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 11 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY