Answered step by step
Verified Expert Solution
Link Copied!

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 =0;
Player: calls damageDone passing in bonusValue for sword or 0.. returns value returned by damageDone
Monster: calls damageDone(0) and returns the returned value.
virtual void defend(int damage)=0;
Player: calculates AC, passes along damage and AC to damageTaken
Monster: calls damageTaken(damage, AC);
virtual void update(Player& player, std::vector& monsters)=0;
Player: lines 44-60 from Goal.6.cpp 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 for_each goes here. for_each now just calls the update...
virtual void print(std::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 damageDone(int modification) const;
does the common bits for attack. Monsters pass in 0, player based on sword
int damageTaken(int damageDone, int AC);
does the common bits for defend.
#ifndef OBJECT_H
#define OBJECT_H
#include
#include
class Object
{
public:
static std::random_device seed;
static std::default_random_engine engine;
enum class Type { player, slime, orc, sprite, dragon, numTypes };
Object(){}
Object(Type 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{0};
int health{0};
int level{0};
};
std::ostream& operator<<(std::ostream& o, const Object& src);
#endif //!OBJECT_H

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Database Technology Edbt 88 International Conference On Extending Database Technology Venice Italy March 14 18 1988 Proceedings Lncs 303

Authors: Joachim W. Schmidt ,Stefano Ceri ,Michele Missikoff

1988th Edition

3540190740, 978-3540190745

More Books

Students also viewed these Databases questions