Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Object.h gets four purely virtual methods: virtual int attack ( ) const = 0 ; Player: calls damageDone passing in bonusValue for sword or 0
Object.h gets four purely virtual methods:
virtual int attack const ;
Player: calls damageDone passing in bonusValue for sword or returns value returned by damageDone
Monster: calls damageDone and returns the returned value.
virtual void defendint damage;
Player: calculates AC passes along damage and AC to damageTaken
Monster: calls damageTakendamage AC;
virtual void updatePlayer& player, std::vector& monsters;
Player: lines from Goalcpp goes here. The part dealing with attacking vs healing. Also playerAttack function is no longer a function, just put the code in the a case.
Monster: The part inside the foreach goes here. foreach now just calls the update...
virtual void printstd::ostream& o const;
the overload of the operator will call this to make sure it the proper one is called!
And two protected methods:
int damageDoneint modification const;
does the common bits for attack. Monsters pass in player based on sword
int damageTakenint damageDone, int AC;
does the common bits for defend.
#ifndef OBJECTH
#define OBJECTH
#include
#include
class Object
public:
static std::randomdevice seed;
static std::defaultrandomengine engine;
enum class Type player, slime, orc, sprite, dragon, numTypes ;
Object
ObjectType name, int strength, int health, int level;
bool isDead;
Type getName const;
int getLevel const;
int getHealth const;
protected:
Type name Type::numTypes ;
int strength;
int health;
int level;
;
std::ostream& operatorstd::ostream& o const Object& src;
#endif OBJECTH
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started