Hey so im making a text based rpg for school and im having troubles with it
i need to add an inventory into my game and im not to sure as to where or how..
this is what i got for player
#ifndef PLAYER_H
#define PLAYER_H
//console Util.h includes <iostream> , <string> and <window.h> and defines
//the NOMINMAX macro. As a result of including ConsoleUtil.h, PLayer will
// also knaow about thoes objects.
#include "ConsoleUtil.h"
class Player
{
private:
enum Items { knife,red_key,bunch_of_keys };
string name_;
unsigned short int age_;
bool isPlaying_;
string current_location_;
protected:
std::string name;
// All properties and methods below the 'public:' declaration will be declared as public.
public:
Player(); // This is the (explicit) default constructor for the player object.
~Player(); // Destructor for the player object.
// Accessors / Getters
// These methods are so syntactically/logically simple that we also include
// the function definiation of tAccessors/Getters within the class declaration.
inline void setName(const string &newValue);
inline void setAge(unsigned short int newValue);
inline void isPlaying(bool newValue);
inline void setCurrentLocation(const string &newValue);
// All properties and methods below the 'private:' declaration will be declared as private.
// An underscore character '_' is post-fixed to the variable name to denote it is marked as
// private.
};
const char *items_str[];
void Player::setName(const string &newValue)
{
name_ = newValue;
}
// unsigned short int is a built-in datatype so we'll pass by value.
void Player::setAge(unsigned short int newValue)
{
age_ = newValue;
}
// bool is a built-in datatype so we'll pass by value.
void Player::isPlaying(bool newValue)
{
isPlaying_ = newValue;
}
Shouldn't an inventory be separate from the player ?
If I were you I would create another header-file INVENTORY_H
and work from there on. Then you would just call upon it in your
PLAYER_H file.