/********************************************************************* C201 Computer Programming II Fall 2006 Dana Vrajitoru & A class to represent the inventory of a shop. **********************************************************************/ #ifndef INVENTORY_H #define INVENTORY_H #include "product.h" const int SIZE_DEF = 10; class Inventory { private: // size is the number of product objects currently used in the // inventory. capacity is the total number of product objects we can // use without having to increase the size of the array. int capacity, size; Product *items; public: // Constructors - Destructor // Constructor with specified size and default value so that we can // use it as default constructor too. Inventory(int nr_items = 0); // Destructor: must delete the array items if it's not NULL. ~Inventory(); // Initialize, reset, resize functions. // Initialize the array items with a given capacity. If the array is // not empty it must delete it. It does not copy the previous // objects in the array. void Init(int nr_items); // Delete the array items and reset all values to 0. void Clear(); // Double the size of the array items and copy all the items from // the previous one to the new one. void Resize(); // Stock manipulation. // Adds a new product to the inventory by inputing it from the user. void Add_new(); // Increases the quantity of an existing item identified by its // name. If the name is not yet used it prints an error message and // returns false. bool Add_by_name(); // Sells a quantity of an existing item identified by name. If there // is no item with that name or if the quantity of the item is less // than the required amount to sell then the function should print // an error message and return false. If the operation is successful // the function should output the total price for those items // (quantity sold times the price). bool Sell_by_name(); // General purpose functions // Print a list of the entire inventory. void Output_all(); }; #endif