Answered step by step
Verified Expert Solution
Link Copied!

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 10,
*- Assign mItems to a new vector of Items with mMaxSize as the size
*- Set mGold to 50.
*/
//default constructor
Inventory()
{
mMaxSize =10; //setting default for mMaxSize equal to 10
mItems = std::vector(mMaxSize); //setting default for mItems as a new vector with the size that is for mMaxSize
mGold =50; //setting default for mGold equal to 50
}
// 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 SetGold(int 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

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

Google Analytics 4 The Data Driven Marketing Revolution

Authors: Galen Poll

2024th Edition

B0CRK92F5F, 979-8873956234

More Books

Students also viewed these Databases questions

Question

What are three myths about mindfulness?

Answered: 1 week ago

Question

4. Choose appropriate and powerful language

Answered: 1 week ago

Question

2. Choose an appropriate organizational pattern for your speech

Answered: 1 week ago