Question: In C++ create the following program - Classes you must create Monster must be an abstract class Each monster has an attack() randomly generate a
In C++ create the following program - Classes you must create
Monster
must be an abstract class
Each monster has
an attack()
randomly generate a number between 0 and strength for each attack (Strength 10 would generate 010)
add up all the damage done
return total damage
a number of attacks
a number for strength u sed during attacking
a string representing the type
accessor for type
Goblin
inherits from Monster
type is Goblin
has 1 attack
has strength of 30
when attacking has a 10% chance of doing double damage
Troll
inherits from Monster
type is Troll
has 2 attacks
has strength 60
when attacking has a 20% of doing 100 damage for each attack
Dragon
inherits from Monster
type is Dragon
has 4 attacks
has strength 100
After the initial 4 attacks a dragon has a 50% chance of gaining an additional attack
IceDragon
Inherits from Dragon
has all the attributes of a Dragon
type is Ice Dragon
After all attacks are made (including the possible 1 additional) it has a 50% chance of the total damage being doubled
FireDragon
Inherits from Dragon
has all the attributes of a Dragon
type is Fire Dragon
After the initial 4 or 5 attacks are complete, has a 50% chance of attacking all over again (includes a new chance of having an additional attack as all Dragons have)
Each class must be defined in a header and implementation file named for the class (*.hpp and *.cpp). All filenames must be all lowercase (Ice Dragon > icedragon) Each classes attack() function must output describing each attack as well as return total damage. See attached example text for good formatting. Each header must have include guards All numbers need to be integers lab5.cpp This file will demonstrate your monsters attacks Use rand() from Use srand(1234) in main Create an array of 100 Monster pointers Randomly fill the array with objects of each type Each type of Monster should have the same chance of being generated (20% rand() % 5) See above examples for ideas of how to do this Loop through the entire array and call attack() on each element of the array and output results free dynamic memory
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
