Using C you will create a simple class hierarchy as the basi

Using C++ you will create a simple class hierarchy as the basis for a fantasy combat game. Your ‘universe’ contains Vampires, Barbarians, Blue Men, Medusa and Harry Potter. Each has characteristics for attack, defense, armor, and strength points as follows.

1. Suave, debonair, but vicious and surprisingly resilient!
2. Think Conan or Hercules from the movies. Big sword, big muscles, bare torso.
3. They are small (6” tall), fast and tough. So they are hard to hit and can take some damage. As for the attack value, you can do a LOT of damage when you can crawl inside the armor or clothing of your opponent.
4. Scrawny lady with snakes for hair. They help with fighting. Just don’t look at her!
5. Why are you reading this? How can you not know who Harry Potter is?
“3d6” is rolling three 6-sided dice, “2d10” is rolling two 10-sided dice, etc.
*Charm: Vampires can charm an opponent into not attacking. For a given attack there is a 50% chance that their opponent does not actually attack them.
*Glare: If a Medusa rolls a 12 in attack, then the target has looked her in the eyes and is turned to stone. The Medusa wins!
*Mob: The Blue Men are actually a swarm of small individuals. For every 4 points of damage (round down), they lose one defense die. For example, when they reach strength of 8 they only have 2d6 for defense.
*Hogwarts: If Harry dies (i.e. strength <=0), he immediately recovers and his total strength becomes 20. If he were to die again, then he’s dead.

NOTE: The sample creatures are unbalanced intentionally. This will help you in debugging your program! Some will win a lot, and others will lose a lot.
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 will subtract the Defense roll from the Attack roll. That is the damage to the defender.

Each class only has its own information or data. When O1 is fighting O2, your program should call O1’s attack function. It will return the damage inflicted. Then O2’s defense function will take the damage inflicted, roll the specified dice and subtract the damage points from the defense. 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. For example, if one object receives 9 points of damage and rolls 3 for its defense, and has an armor of 4 and strength point of 8, it would take 9 subtract 3, and then 4 for the armor, to receive 2 points of damage, and its new strength point will be 8-2=6.

You need to create a Creature base class. Then you will have a subclass for each of these characters. Note that the Creature class will be an abstract class. For our purposes right now, 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. The only value that can change is the Strength Points.

Program file(s) with the implementation of these five creatures inheriting from a single parent and a makefile to run your program.

- In each of these, the virtual attack and defense functions must work correctly:
- Create the base class
- Create the Barbarian class
  -  Create the Vampire class, overload or redefine defense function
- Create the Blue Men class
- Create the Medusa class, overload or redefine attack function
- Create the Harry Potter class
- Create a test driver program to create character objects which make attack and defense rolls required to show your classes work correctly

Type Attack Defense Armor Strength Points
Vampire1 1d12 1d6* Charm 1 18
Barbarian2 2d6 2d6 0 12
Blue Men3 2d10 3d6 3 12* Mob
Medusa4 2d6* Glare 1d6 3 8
Harry Potter5 2d6 2d6 0 10/20* Hogwarts

Solution

//main.cpp

===============================================================

//barbarian.hpp

=====================================================================

//bluemen.cpp

============================================================================

//bluemen.hpp

========================================================================

//creature.cpp

======================================================================

//creature.hpp

==========================================================================

Using C++ you will create a simple class hierarchy as the basis for a fantasy combat game. Your ‘universe’ contains Vampires, Barbarians, Blue Men, Medusa and H
Using C++ you will create a simple class hierarchy as the basis for a fantasy combat game. Your ‘universe’ contains Vampires, Barbarians, Blue Men, Medusa and H

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site