CSCI-2962 Homework 3

Due Tuesday, November 6th, at 11:59:59pm EST

Homework 3 FAQ now available.

A Sample Inventory is available as well.

You are to create a program that will read in an inventory of a media store (ie, CDs, DVDs, books, etc). The inventory file will be set up so that each item is on a separte line, in the format
ProductCode|Title|Price     For example:

CD123|Perl on CD|$19.99
DVD432|Larry Wall is My Hero|$25.00
TEXT7342|The Camel is Great and Here's Why|$45.63
The name of the inventory file will be read in from the command line. Once the file is opened, you are to create a simple menu interface that has the following options:
  1. Start a new order
  2. Display entire inventory
  3. Search for item in inventory
  4. Add item to order
  5. Remove item from order
  6. Display current order
  7. Submit order and exit program
Each of these options are to be implemented in their own subroutines (with the possible exception of Start a New Order). That means your program should have a minimum of 6 user-defined subroutines. Here is a brief description of each functionality:

Start a new order
The user must select this option before being able to add, remove, display order, or submit. When the user selects it, open a new file for writing so that you can print to it whatever the user adds from the inventory. This option can only be selected once per program run. If the file already exists (ie, the program has been run before) feel free to clobber the old order file and begin a new one.
Display entire inventory
Print out the contents of the inventory file, so that the user can see each product's title, code, and price. Do not simply print out the file as is; it should be in an easy-to-read format.
Search for an item in inventory
This is probably the most complicated functionality. You must create a very simple search engine. Prompt the user for a search query. If the user enters a single word, print a list of all inventory items containing that word in the title. If the user enters a phrase surounded by quotes, return a list of all inventory items containing that phrase in the title. If the user enters two words separated by the word AND, return a list of all inventory items containing both words in the title, but not necessarily next to each other. If the user enters two words separated by the word OR, return a list of all inventory items containing either word in the title. If the user enters two or more words without quotes and not separated by AND or OR, you may return an error. Likewise, you do not have to account for 'complicated' searches: the only searches the user is allowed to do are: Note, however, that if the user tries to do anything more complicated (for instance - word AND "phrase", or word AND word OR word), your program should print out an error message, and should not die. In all cases, the search should be entirely case insenstive (including the AND and OR keywords)
Add item to order
Prompt the user for the Product Code to add, and the quantity of that item to add. Then add that many of that product to your order (obviously, an error message should be generated if the product code doesn't exist in the inventory)
Remove item from order
Prompt the user for the Product Code to remove from the order. If there are more than one of that product already in the order, prompt the user for how many of those products to remove, and then remove the appropriate product.
Display Current Order
Print out the contents of the current order, including product code, product title, individual price, quantity ordered, and total price for that product. Once all items are printed, print a total price for this order. Note that if two of the same item are ordered, they are to be listed as one instance, giving the quantity of two. Do not print out separate listings for each instance of the same item.
Submit order and exit program
Write the current order to the file opened in the first option. Print out a message saying something like "Order submitted, thank you.", and then exit the program.

Grading Scheme

The same caveats from HW2 apply here, in regards to compilation, error messages, and style.

As always, 5 Above & Beyond credits are available for additional functionality.

Submission Guidelines

UPDATE - 10/31/2001

I announced in class today that I will allow you to work in pairs on this project. If you choose to do so, you may work with ONE other student currently registered for this course. When your project is ready, one of you will email your submission to Jusin and myself.

As previously, send one email to both lallip@cs.rpi.edu and mcguij2@cs.rpi.edu containing your name (and your partner's name, if applicable), RCS ID (and your partner's RCS ID, if applicable), and the RCS machine on which your program was tested. This means that your program *must* work on the RCS network. Running the program on your own Windows machine, your own Mac, your own Linux box, etc etc etc are not good enough.
Attach the one file containing all your source code. Make the subject of the email "Perl Homework 3" and make the name of your file be your RCS ID, followed by whatever extention you like. If you worked in pairs, make the name of your file the RCS ID of the first member of your group, followed by underscore, followed by the 2nd member's RCS ID, followed by an extention. For example: lallip_mcguij2.pl
By the way, your "RCS ID" is NOT the same as your "Rensselaer ID Number" (RIN). Your RCS ID is what you use to log into the RCS machines, and what precedes "@rpi.edu" in your email address. Your RIN is what you use to log onto SIS, to check your Perl grades, and what is printed on your ID card. Please try not to confuse the two...

The project is due Tuesday, November 6th, at 11:59:59pm EST. Submissions will be accepted up to Wednesday, Nov. 7th at 11:59:59pm EST at a deduction of 20%.

Friendly advice

This project is somewhat larger than the last two. While I do not believe it to be substantially more difficult, it is likely to be more time consuming. I would advise not waiting until the last moment, especially since Justin and I will likely be backed up with other students asking last-minute questions.