Answered step by step
Verified Expert Solution
Question
1 Approved Answer
One of the most important skills in our craft is interpreting error messages. Remember the ones you receive when you attempt to compile the unmodified
One of the most important skills in our craft is interpreting error messages. Remember the ones you receive when you attempt to compile the unmodified code.
The key abstractions employed in this program are Item, ItemStack, and Inventory. Complete ADT implementations have been provided for the former two. A partial implementation has been provided for the Inventory. Your task is to finish the Inventory.
You can implement the Copy Constructor, findMatchingItemStack, and display with loops.
You can, alternatively, use the builtin C functions discussed in Review Example if you like a challenge
You must implement:
Copy Constructor
Assignment Operator
Note this is already provided and complete. Refer to our discussions of the copyandswap method.
Once you have completed the Copy Constructor, you are done with the Big
Inventory::isFull refer to documentation in Inventory.h
Inventory::findMatchingItemStackIterator refer to documentation in Inventory.h
Inventory::addItemStackNoCheck refer to documentation in Inventory.h
Inventory::mergeStacks refer to documentation in ItemStack.h
Inventory::display. This must generate the Inventory summary.
Note there is no formatting applied with setw. All spacing consists of hardcoded spaces.
Please only make changes in inventory.cpp
#include
#include
#include "Inventory.h
Allow the compiler to define the remaining
comparison operators
using namespace std::relops;
Inventory::Inventory
:Inventory
Inventory::Inventoryint n
thisslots n;
thisallItemStacks.reserven; only works for std::vector
Inventory::Inventoryconst Inventory& src
@todo implement this function
Inventory::~Inventory
Done! Be able to explain why.
int Inventory::utilizedSlots const
return allItemStacks.size;
int Inventory::emptySlots const
return slots utilizedSlots;
int Inventory::totalSlots const
return slots;
bool Inventory::isFull const
@todo implement this function
return false; replace this line
Inventory::iterator Inventory::begin
return allItemStacks.begin;
Inventory::iterator Inventory::end
return allItemStacks.end;
Inventory::constiterator Inventory::begin const
return allItemStacks.begin;
Inventory::constiterator Inventory::end const
return allItemStacks.end;
void Inventory::displaystd::ostream &outs const
outs Used utilizedSlots of slots slots"
;
@todo implement the rest of function
spaces before each ItemStack line
Inventory::iterator Inventory::findMatchingItemStackIteratorconst ItemStack& itemStack
@todo implement this function
return allItemStacks.end;
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