QuestionQuestion

You will create a simple class hierarchy as the basis for a fantasy combat game. Your ‘universe’ contains Goblins, Barbarians, Reptile People, Blue Men and possibly others. Each will have characteristics for attack, defense, armor, and strength points.

Type, Attack, Defense, Armor, Strength Points
Goblin4, 2d6*Achilles, 1d6, 3, 8
Barbarian1, 2d6, 2d6, 0, 12
Reptile people2, 3d6, 1d6, 7, 18
Blue men3, 2d10, 3d6, 3, 12
The shadow3, 2d10, 1d6, *Special, 12
3d6 is rolling three 6-sided dice. 2d10 is rolling two 10-sided dice.

*Special- The Shadow can manipulate perceptions of others. For a given attack there is a 50% chance that The Shadow is someplace else and no damage is received. Note- Implement this AFTER you have tested the normal defense function. But first save a copy of that file. Just in case.

*Achilles-When fighting anything but another Goblin they might get lucky and cut an Achilles Tendon. If a Goblin rolls a 12 in an attack then the target has his/her attack roll halved for the remainder of the combat. Note- Implement this AFTER you have tested the normal attack function. But first save a copy of that file.

To resolve an attack you will need to generate 2 dice rolls. The attacker rolls the appropriate number and type of dice under Attack. The defender rolls the appropriate number and type of dice under Defense. You subtract the Defense roll from the Attack roll. That is the damage. To apply the damage you subtract the Armor value. The result is then subtracted from the Strength Points. That value becomes the new Strength Points for the next round. If Strength Points goes to 0 or less then the character is out of the combat. HINT: Carefully think through how the attack and defense functions will interact.

You need to create a creature, or character class. Call it what you choose. Then you will have a subclass for each of these characters. Note that the parent class will be an abstract class. Each subclass will vary only in the values in the table. Since each starts with the same data elements you will only need one constructor. It is part of your design task to determine what functions you will need. Maybe attack() and defense()? The only data member that can change is the Strength Points. Incorporate them into your class hierarchy.

You must complete your design document. It must include a class hierarchy. In your reflections you can discuss how the original design may have changed as you worked through the problem. You must also submit a test plan. The test plan should cover all logic paths. So you should have each character type have combat with all character types (including another of its own). Remember to submit these documents as PDF files.

To test your classes create a program that instantiates 2 creatures of the type specified by the user; such as Barbarian vs Goblin, or Blue Men vs The Shadow. Conduct rounds of combat until only one has strength points remaining. Can you have a draw? That is can both run out of strength points in the same round?

What you need to submit:
Your program file(s) with the implementation of these five creatures inheriting from a single parent.
You should have a header file and source file for each class
You should have a program file containing your code to test and demonstrate the use of the other classes. This will be a program that just runs a combat between 2 creatures.
Your design document (basically the class hierarchy)
Your test plan
Your reflections document.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include "Goblin.h"

Goblin::Goblin():Creature(8, 3, "Goblin") {   
}

Goblin::Goblin(const Goblin& orig) {
    this->strengthPoint = orig.strengthPoint;
    this->armor = orig.armor;
    this->name = orig.name;
    this->halved = orig.halved;
}

Goblin::~Goblin() {
}

double Goblin::attack(Creature* c){
   
    double attackPower = (rand() % 6) + (rand() % 6) + 2;
   // double attackPower = 12;
    if (attackPower == 12 &&
            this->name != c->getName()) {      
       c->halve(); // Achilles, halve the attack power of the other creature
       cout<<c->getName()<<"'s attack power is halved\n";
    }
    return attackPower;
}

double Goblin::defense(double attackPower){
    double defensePower = (rand() % 6) + 1;
    double damage = attackPower - defensePower;
    damage -= armor;
    if (damage > 0) {
       strengthPoint = strengthPoint - damage;
    }
    cout<<this->name<<" defense power:\t"<<defensePower<<"\n";
    return damage;
}...
$80.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats