CPSC131 CSU Fullerton Sp’19 Lab 1 C++ Data Structures GildedRose

this is the first lab of many!! if i get an 90+ i will be working with you for the rest of the semester if you’d like that! 🙂

do as asked on a college student’s level, don’t make it look super professional, just enough to get an A without blowing the professor’s mind haha

comments are very important for grades and the professor.

i would like them to be long for me to read and understand what the line in doing and then i’ll shorten them before submitting it.

the main.cpp file is not to be edited, it will be used to test our work once we’re done.

the files needed will be attached..

thank you!

Objective:

You are given a partial implementation of one header file, GildedRose.h. Item is a class that holds the information for each item for the inn. GildedRose is a class that holds an internal listing of many Item objects. This inventory should hold at least 10 items. For this you can use arrays, the std::array class, or even the vector class.

Complete the implementation of these classes, adding public/private member variables and functions as needed. You should choose an appropriate data structure to maintain this inventory with an unknown size known only at runtime. Your code is tested in the provided main.cpp.

You will need to implement the following functions:

  • Constructors/Destructors – Initialize your data. Allocate memory if using a native array. The destructor should deallocate memory if using a native array.
  • size() – This should return the number of items currently for sale (this is different from the max).
  • get(size_t) – This should return the item with the matching index. For example if given an index of 3, you should return the item at index 3 in the list.
  • add(Item) – This should add another item for sale in the Gilded Rose by adding it to your inventory.
  • operator[](size_t) – This should perform identical to the get(size_t) function.

Initially the given code will not compile. As you complete the code, the tests should start to pass in main.cpp.