1)
Using the Book class declaration, write the book.cpp file
and define all of the member functions that are declared in the file
book.h. (Do not change book.h in any
way. Just take the existing class interface and fill in the function
definitions). Notice that there are only four genres of books in
this class: FICTION, MYSTERY, SCIFI, and COMPUTER. The
expected functions behaviors are described in the comments of this header
file.
2) Write a class called Store (filenames are store.h and store.cpp). A Store object should contain at least the following information: the amount of money in the store cash register and a book inventory list. There is no size limit to the inventory list, so it should be implemented with a dynamically allocated array. (This means you'll need an array of Book objects). You can add any public or private functions into the Store class that you feel are helpful. In addition to the Store class itself, you will also create a menu program to manage the inventory of books. However, the Store class will be able to do much of the work, as the Store member functions will be the interface between the menu program and the internally stored data (cash register and list of books).
Rules for the Store class:
3) Write a main program (filename menu.cpp) that creates a single Store object and then implements a menu interface to allow interaction with the object. The program should begin by asking the user to input the starting amount of money in the store's cash register (as a double). This should be stored in the Store object. Your main program should implement the following menu loop (any single letter options should work on both lower and upper case inputs):
A: Add a book to inventory F: Find a book from inventory S: Sell a book D: Display the inventory list G: Genre summary M: Show this Menu X: eXit the program
Behavior of menu selections:
Always ask for user input in the order specified. Remember, all user inputs described in the menu options below should be done by the menu program (not inside the Store class). Such input can then be sent into the Store class -- the Store class member functions should do most of the actual work, since they will have access to the list of books and the cash register. For all user inputs (keyboard), assume the following:
F: This option should allow the user to search for a book in the inventory list by title or by author. When this option is selected, ask the user to enter a search string (may assume user entry will be a string 30 characters or less). If the search string matches a book title, display the information for that book (output format is described in the Display function of the Book class). If the search string matches an author in the list, display the information for all books by that author. If no matching books are found, display an appropriate message informing the user.
S: This option should allow a sale to be made. When this option is selected, ask the user to type in the title of the book (you may assume that book titles in the list will be unique). Remove this book from the inventory list, and since it is being purchased, add the purchase price into the store's cash register. If there is no such title, inform the user and return to the menu.
D: This option should simply display the entire inventory list, one line per book, in an organized manner (like a table). Each line should contain one book's information, as described in the book.h file. Also, display the total number of books in the inventory list, as well as the current amount of money in the store cash register.
G: This option should list the inventory contents for one specific genre. When this option is selected, ask the user to input a genre. For the category selected, print out the contents of the inventory list, as in the Display option, but for the books matching the selected genre only. (e.g. list all of the Mystery books). After this, also display the total quantity, as well as the total cost (the sum of the prices), of the books in this genre.
M: Re-display the menu.
X: Exit the menu program. Upon exiting, print out
the final amount of money in the store cash register.
5) General Requirements:
double amount = 34.6751 cout << setprecision(2) << fixed; // set manipulators cout << amount; // print the value // x will now print to two decimal places: 34.68
Submit the following files through the web page in the usual manner:
book.cpp store.h store.cpp menu.cpp
You can run my version of the menu executable from linprog.cs.fsu.edu with the command:
~myers/copprog/menu4