trouble with class and member functions

November 21, 2010 at 16:12:36
Specs: Windows XP
i already have class definition for the representation of characters in an RPG (computer game). To start with, objects of your RPG character class must store the following attributes 1: a name, 2: a description (i.e., what they look like), 3: experience points, 4: health points, 5: attack points, 6: a location in the game world (an integer called currentLocationID).

i need to add mutators for setting the absolute value of data members, add functions for making relative changes to your class. These will be called addHealthPoints(), addExperiencePoints(), and addAttackPoints(), along with subtractHealthPoints(), subtractExperiencePoints() and subtractAttackPoints(). These should accept one integer argument in order that, for example, when the character drinks a health potion, their health points can be increased by a specific amount, and when the character is struck by another character, a specific value can be subtracted from their health, contingent on the strength of their opponent.

but i dont understand how to can any one help me?

See More: trouble with class and member functions

Report •

November 21, 2010 at 16:40:12
Really? You want us to do your C++ homework? And you're in a class that expects you to be able to program in C++?

How To Ask Questions The Smart Way

Report •

November 22, 2010 at 10:40:17
looking at what you've posted, you've got all you need. think of the member functions just as you would a function in a program without a class; for example,


you're required to add an integer parameter, and it *probably* doesn't return a value.
void addHealthPoints(const int &val) { ... }

all that's left is manipulating "val" so that it meets the requirement of the appropriate data member, which I suspect would be "health points." no spaces in declaration though... your compiler will spit out an error.


Report •
Related Solutions

Ask Question