Home | |
Schedule | |
Assignments | |
Lectures | |
Resources
Project Five Specifications Nile.comDue Date: Friday, May 2, at 10:00 a.m. NOTE: Read through the project description below, but before you begin implementation, make sure to read the specifications for the project check that is due on April 25. Introduction. This project familiarizes you with the recently taught data types such as strings, structs, classes, arrays of structs, arrays of classes and their input and output to and from files. This project will be taking you much closer to "real world" applications. Your program will handle several functions that might be performed by a program for an on-line store such as Amazon.com (although those programs are not normally written in C++). The function main( ) and associated functions will be written in a file named proj5.cc. In addition, a library of functions written to manage the inventory and orders will be written in the file orders.cc and the associated header file will be orders.h. Finally, there is a customerRec class that is defined in the header file customerRec.h and implemented in the file customerRec.cc. Overview. You have just been hired (stock options and all) to work for the newly formed dot-com company, Nile.com. Although it is now in its infancy, the founders fully expect it to grow, and as the name implies, someday rival the mammoth internet store, Amazon.com. Unfortunately, the server has crashed, and they need you to create a new program to manage new orders and keep track of the names and addresses of customers who are ordering each item. You need to work quickly so that they can get back to selling those classic books, CD's, videos and games, such as the CD from that well known group, "The fully dressed ladies" and the hot new game of trivia and easy money, "Trivial Millionaires". In brief, you need to set up an program that displays an interactive menu that offers a choice between four tasks. The first task lists the items for sale along with their price and the number currently in stock. The second processes the requests of customers to purchase one or more items. If there are enough items in stock, the customer's name is added to a list of customers to receive that item. If there are not enough items, the customer's name is added to a list of people waiting for back-orders of goods. The third task creates a file containing the current information about each item in the inventory, including the names and addresses of all customers who have successfully ordered that item. The fourth task creates a different file with a list of all the customers waiting for back-ordered items. Your new boss has informed you that the information about all the items currently in stock (including price, number in stock, etc.) has been saved on a separate disk, so it is available for your program to read in.
Specifications:
Some of the constants, typedefs and structs, listed in the orders.h file are provided for you to use. An electronic copy of these files can be found in the directory,
If you copy all the files from this directory, you will get, among other things, copies of orders.h and customerRec.h. You may not change any of this code, but you should complete it with your own function prototypes, documentation or anything else you deem appropriate.
2. Implementation of CustomerRec class member functions.
3. Local variables in main( )
int numItems = 0; Inventory itemList; int numBackOrders = 0; BackOrderList backOrders; Note that these will have to be passed as parameters to several functions. Do not make these global variables.
a) Reading in the data: The main( ) program should call a function, ReadInventory(), to read in data from proj5.dat. The prototype for ReadInventory( ) is in orders.h. It should take two parameters: an integer to keep track of the number of items you read in, and an Inventory in which you should store the items you read in. You should implement ReadInventory( ) in the orders.cc file. There is a sample proj5.dat file in the ~csci131/PROJECTS/PROJ5 directory that you should use to test ReadInventory( ). The information should be read into the array, itemList, until the end of the file is reached. Keep a running count of how many items are for sale in the variable called numItems. The information for an item occupies 4 lines. One line for the name, one for the price, one for the type of item (e.g. Book, CD, Game, etc.) and the final line for the number of items currently in stock. Here is an example: The bold and the ugly 26.94 Book 27 As you read in each item, you should take the opportunity to initialize the numCustomers and the numOrdered data members of each element of the Inventory array. You should initialize these data members to zero. Otherwise you will have to write separate code to loop through the inventory and initialize these values. When all the items have been read in, and you have performed all other necessary initializations, close the file and report to the user the completion of data input and the number of items available in the inventory. The message should look like this (although the number of items will depend on how many there are in the input file): Inventory has been read. There are currently 6 items for sale. Note that the correct functioning of much of the rest of the project depends on the file being correctly read in and stored. You are strongly encouraged to write and debug this part of the code first (perhaps in conjunction with the code to print out the inventory list) before proceeding with the rest. b) Displaying the menu: Once the data is read in, the main( ) function should display a menu with the various options. (You might want to write a separate function to display the menu. This is good programming technique--dividing your code into subtasks performed by separate functions). Your program should then prompt the user to enter a choice (don't forget to echo print). It then calls the appropriate function to perform the task corresponding to that choice. The options provided in the main menu are the following: (L) Print a list of the items for sale. (P) Process a customers purchase requests. (I) Create a file with the current inventory status. (B) Create a file with customers waiting for backorders. (Q) Quit. The user continually chooses a function by typing the corresponding character, until Q is entered, at which point the program exits. The menu should be reprinted on the screen between different choices. If some selection other than an acceptable one is typed by the user, the user must be informed of the error and then asked to respond to the menu again until he/she enters a valid response. (The response should be accepted if the user response with either the uppercase or the lowercase form of the character).
5. The ( L ) option:
PRODUCT TITLE CATEGORY PRICE NUMBER IN STOCK The bold and the ugly Book 26.94 27 The fully dressed ladies CD 12.37 34 My Lunch with Andre Video 19.99 1
6. The ( P ) option:
The function will begin with a prompt for the user to type in information for creating a CustomerRec object. Thus, the function will ask the user to type in her name, then it will ask for her address. These should both be recorded in a locally declared object variable of type CustomerRec, using the appropriate member functions of the CustomerRec class. The function will then ask the user if she would like to make a purchase. If the answer is yes, it will prompt her to enter the name of the item she wants to purchase. (Do not forget to echo print). Your function should then search the array, itemList, to determine whether the item requested is one of the items for sale. If the item is not found, an appropriate error message should be given, and the user again asked if she would like to make another purchase. If the item is found, the user should be asked for the quantity she would like to purchase. This information, along with information about the customer's name and address, the item's name and price should be stored in the current element of the array, shopping. In addition to updating the ShoppingList, the itemList entry for the item requested should be updated to increase the numOrdered member by the amount the customer has ordered. If the updated number ordered is more than the number of items in stock for this item, the customer should be informed that the item is back-ordered and there will be a delay in delivery. The current RequestRec should be added to the list of requests that are backordered (the array, backOrders). Don't forget to update the number of back-orders. The item should remain on the customer's shoppingList. If the updated number of items ordered is still less than or equal to the number of items in stock, the current RequestRec should be added to the customers array that is part of the requested item's ItemInfo struct, and the numCustomers should also be updated. Regardless of whether or not the item is back-ordered, the user should be informed of the purchase and the total price for that purchase: You have ordered 2 copies of The fully dressed ladies. Unit Price: 12.37 Total Price: 24.74 After processing a purchase request, the user should then be asked whether she wishes to make another purchase. If so, the above process should be repeated, starting with a prompt to enter the name of the item. If the user responds that they do not want to make another purchase, the function should print out (to the monitor) a list of the items ordered, along with the quantity and unit prices and the total price of the entire purchase (this list should include back-ordered items as well): Customer Order: Name: Annie Hall Address: 1212 New York Ave, New York, NY 01111 ITEM PRICE QUANTITY TOTAL The fully dressed ladies 12.37 2 24.74 The bold and the ugly 26.94 3 80.82 Total Cost = 105.56 Following this report, the control should return to the main( ) function and the menu should be re-displayed.
7. The ( I ) option.
Entire Inventory database Listing Item: The bold and the ugly Price: 26.94 Number in stock: 27 Number ordered: 6 Name and Address Quantity 1 Annie Hall 3 1212 New York Ave, New York, NY 01111 2 George Shaw 3 3434 Pygmalion Circle, Fair City, CA, 94111 Item: The fully dressed ladies Price: 12.37 Number in stock: 34 Number ordered: 2 Name and Address Quantity 1 Annie Hall 2 1212 New York Ave, New York, NY 01111 Item: My Lunch with Andre Price: 19.99 Number in stock: 1 Number ordered: 2 Item: The March Hares Price: 15.33 Number in stock: 5 Number ordered: 0 After the completion of the report, notify the user that it is done, close the file and return to main().
8. The ( B ) option.
There are 2 customers waiting for back-ordered items. 1 Name: George Shaw Address: 3434 Pygmalion Circle, Fair City, CA, 94111 Item: My Lunch with Andre Number ordered: 2 2 Name: Annie Hall Address: 1212 New York Ave, New York, NY 01111 Item: Brahms Lullaby Number ordered: 5 After the completion of the report, notify the user that it is done, close the file and return to main().
9. Location of functions.
Program testing: As you write your program, you can test it along the way by compiling and running it by itself. You can compile your program using the command: g++ -g -Wall proj5.cc orders.cc customerRec.cc -o proj5 You can then run it by typing, proj5. When you have finished your program, you can test it more thoroughly using the test5 program. The directory ~csci131/PROJECTS/PROJ5 contains, among other things, files named proj5.dat, terminal.inp and test5. Copy these files into a directory which also contains your proj5.cc, orders.cc and orders.h, customerRec.h and customerRec.cc. Then type test5. The test5 script will compile your program and run using the commands from terminal.inp and the inventory data in proj5.dat. The terminal output from this test run will be placed in a file named output5 and the files, inventory.dat and backOrders.dat (created by your program). You can compare your output with the files model5.out, model.inventory and model.backOrders in the ~csci131/PROJECTS/PROJ5 directory.
To submit your finished project:
2. Hand in a hard copy of the files you submitted electronically. Hand this to your instructor in class on the project's due date. 3. Print out the grading header, put your name at the top of it, and hand it in with your hard copy. Get started early and have fun! Honor code: Please review the collaboration policy on the main course webpage. Also refer to the math and CS department honor code policy. Home | | Schedule | | Assignments | | Lectures | | Resources
|