2 Learning Outcomes
In this assignment you will learn to
1. Use inheritance.
2. Use linked list type data structures.
3. Make a UML diagram of the application.
In this assignment you will be writing a (vastly simplied) inventory system for a store / warehouse (like Ikea or
Costco) using C++.
This store will sell a number of Products. Each product has a StoreLocation. These locations are in the main
store area where shoppers shop. Each product may have zero or more overstock locations in the warehouse. These
are stored on skids (Figure 1) of all the same Product wrapped in plastic. We will call these WHLocations (warehouse
locations). Because WHLocations can only accept skids, they will be treated dierently than StoreLocations, and
we will use inheritance to implement to two dierent styles of Locations.
To help us with our inventory system we will use a few dierent data structures. We will use the linked List
that we have seen in class, but with some modications. We will also implement a Queue, which is a linked list but
with dierent rules for adding and removing. We will also use primitive arrays.
4 Classes Overview
This application will consist of 8 classes. The classes are listed below along with their respective categories.
1. Location (Entity object):
(a) A virtual base class for StoreLocation and WHLocation classes.
2. StoreLocation (Entity object):
(a) Concrete implementation for in-store product locations.
3. WHLocation (Entity object):
(a) Concrete implementation for warehouse product locations.
4. Product (Entity object):
(a) Contains information about the product, including the StoreLocation and WHLocations it is stored in.
5. List (Container object):
(a) A list of Products that can grow arbitrarily large.
6. Queue (Container object):
(a) A rst-in-rst-out (FIFO) data structure for storing WHLocations. The FIFO nature of the data structure
ensures that we use older stock rst.
7. Store (Control object):
(a) Provides an interface for interacting with the inventory system.
8. Control (Control object):
(a) Controls the interaction between the inventory system (Store) and the user.
9. View (View object):
(a) Collects user input and provides system output.
All member variables are private unless otherwise noted. All member functions are public unless otherwise noted.
Some return values are not explicitly given. You should use your best judgment (they will often be void, but not
always). ALL CLASSES MUST HAVE A PRINT FUNCTION. This print function should display the metadata of
the class using appropriate formatting.
Once you download and unzip the assignment les you will nd some full classes (Control and View) and some
classes with partial implementations (Product and Store). There is a Makefile provided (which you may adjust as
needed), and the les main.cc and defs.h. It will not compile, and there will be errors that should clear up as you
design and implement the rest of the classes
5.1 The Location Class
Implement the Location base class. For the virtual functions add and remove, you should carefully consider what
code goes in the base class and what code in the derived class, or whether these should be pure virtual.
1. Member variables:
(a) string id: The label of this location.
(b) string product: The name of the product stored at this location. Although this is slightly unrealistic,
since normally we would uniquely identify a product by its sku code, in this program we will also use the
product name as the unique identier (this is due to the circular reference problem mentioned in Section
(c) int quantity: The quantity of product stored at this location.
(d) A string constant NONE = “Empty”. This should be a class variable. When there is no product in the
location, we will set the product variable to NONE.
2. Make getters for the member variables (except for NONE).
3. Make a two argument constructor that takes a character code (such as ‘A’ or ‘B’) and a number. This
constructor should concatenate the character code with the number and store it in the id string. For instance,
if I pass in ‘A’ and 23 as arguments, then id = “A23”.
4. Member functions. In addition to the functions listed here, you may add other functions at your discretion.
Be sure to properly document them.
(a) bool isEmpty(). Returns true if quantity == 0 and false otherwise.
(b) bool isAvailable(). Returns true if product == NONE and false otherwise.
(c) void print()
5. Virtual member functions. These functions will behave dierently depending on the subclass that calls them.
(a) int getCapacity(): This will return the maximum number of products this location can hold.
(b) A bool add function that takes a string (product name) and an integer (quantity) as arguments. The
integer is an input/output variable which will be described in the subclass.
(c) A void remove function that takes an integer (quantity) as an argument. The integer is an input/output
variable which will be described in the subclass.