You are an entrepreneur and you plan to open a new bookstore with different types of item in
your inventory. You will have books, CDs and magazines. Every item will have a serial number,
name, published date (date, month, year) and price. But as you have 3 types of products they
will have different properties. Books will have an ISBN number, number of pages, genre of
book. CDs will have play time and description. Magazines will have its frequency of publishing
and weather it is a local or international magazine.
Your task as the manager of the bookstore is to manage your inventory. You will read the
inventory from a .txt file and store it in arrays for 3 different types of objects. You will then write
search functionality. Given a serial number you have to print out all the details of the given
number if it exists or else return false. Also write a function to add and remove stuff from the
Your code should have a class for each type of product. You should then store the inventory in
3 different arrays. Then you will write 3 functions:
1. Insert – Given an item put it in the correct array
2. Delete – Given a serial number it should delete the object from the array and shift the
array if necessary.
3. Search – Given a serial number print the details of the product (use function overloading)
or print “Not found” if it is not found
Your main function will first read the initial inventory from a file and store it. Then, your program
needs to read a file of actions that your program needs to perform. Both the files will be passed
as command line arguments.
Contents of inventory file look like this:
1, Book, Harry Potter, 10-10-1995, 30, ISBN123456, 800, Fiction
Where 1 is the serial number, then we have what type of product it is, then name, publishing
date, price. After that the columns will depend on what type of product it is.
Contents of action file will be something like:
31, Book, Lord of the Rings, 1-09-1992, 20, ISBN131356, 2000, Fiction
To process the action file, group the lines in sets of 2. The 1st line of each set will tell you the
action (1- Insert, 2- Delete, 3 – Search) The 2nd line will give you the new data for option 1 or
will give you serial number that you have to search/ delete for option 2/ 3.
Also you should print your entire inventory at the end of the program
Before you start coding
Write the pseudocode for your program. There are a lot of details needed in this program that
are not explicitly outlined in this write-up. If you just start coding before thinking through the
problem, you might spend a lot of time re-doing your work.
Submitting Your Code:
Submit your assignment to Canvas
Submit your .cpp file through Canvas using the Assignment 2 Submit link. Make sure your code
is commented enough to describe what it is doing. Include a comment block at the top of the
.cpp file with your name, assignment number.
What to do if you have questions
There are several ways to get help on assignments in 2275, and depending on your question,
some sources are better than others. There is a discussion forum on Piazza that is a good place
to post technical questions, such as how to shift an array. When you answer other students’
questions on Piazza, please do not post entire assignment solutions. If, after reading the
assignment write-up, you need clarification on what you’re being asked to do in the assignment
ask the TA or the Instructor. We will be monitoring Piazza regularly.