Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include Console.h #include Item.cpp #include class Inventory { / * * TODO: Define three member fields * = = = = = =
#include "Console.h
#include "Item.cpp
#include
class Inventory
TODO: Define three member fields
An int called mMaxSize
An vector of Items called mItems
An int called mGold
Member fields for MaxSize, Items, and Gold
private:
int mMaxSize; Initilizing field for MaxSize called mMaxSize
std::vectormItems; Initilizing field for Items as a vector called mItems
int mGold; Initilizing field for Gold called mGold
public:
TODO: Write a default constructor
By default, it should:
Assigns the mMaxSize to
Assign mItems to a new vector of Items with mMaxSize as the size
Set mGold to
default constructor
Inventory
mMaxSize ; setting default for mMaxSize equal to
mItems std::vectormMaxSize; setting default for mItems as a new vector with the size that is for mMaxSize
mGold ; setting default for mGold equal to
TODO: Create a Getter and a Setter for the mGold field named "GetGold" and "SetGold"
setting up mGold accessor
int GetGold
return mGold; return mGold
setting up mGold mutator
int SetGoldint gold
mGold gold; setting default mGold equal to gold
TODO: Write a method called AddItem
The method should return a bool returns
a bool and takes an Item parameter.
This method should iterate through the
mItems vector, looking for any vector element
that is default.
If a default Item is found, it should assign
that vector element to the Item passed in and
return true. Otherwise it should return false.
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