Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
