ItemStack

 

One of the most important skills in our craft is interpreting error messages. Remember the ones you receive when you attempt to compile and run the unmodified code.

The key abstractions employed in this program are Item, ItemStack, and Inventory. Complete ADT implementations have been provided for Item and Inventory.

A partial implementation has been provided for the ItemStack. Your task is to finish the update ItemStack ADT.

This assignment is smaller than the previous two (in terms of code and number of new concepts). Most of your time will be spent reviewing the basics of pointers. Spend the time reviewing. Practice with pointers. You will need to use pointers (in one form or another) for the reminder of the semester.

You must implement the:

  1. Copy Constructor
  2. Destructor
  3. Assignment Operator
    • Note this is already provided and complete. Refer to our discussions of the copy-and-swap method.
    • Once you have completed the Copy Constructor, Destructor, and swap you are done with the Big-3.
  4. Logical Equivalence (i.e., operator==).
  5. Less-Than (i.e., operator<).
  6. swap

Refer to the comments in each function for additional detail.

 

If you implemented everything correctly you will see:

Inventory:
 PASSED -> testDefaultConstructor
 PASSED -> testConstructorSizeN
 PASSED -> testAddItemStackNoCheck
 PASSED -> testAddItemWithDuplicateItems
 PASSED -> testAddItemAfterFull
 PASSED -> testCopyConstructorForEmpty
 PASSED -> testCopyConstructor
 PASSED -> testAssignmentOperator
 PASSED -> testDisplay
ItemStack:
 PASSED -> testDefaultConstructor
 PASSED -> testSecondConstructor
 PASSED -> testCopyConstructor
 PASSED -> testAssignment
 PASSED -> testAddItems
 PASSED -> testAddItemsFrom
 PASSED -> testLogicalEquivalence
 PASSED -> testLessThan
 PASSED -> testDisplay
 PASSED -> testSwap

 

Files to Submit:

  • ItemStack.cppi.e., your version of the ItemStack ADT Implementation.