Gift - the Problem Description
CS 330 - Fall 2010 - Dr. Hutchens

Goals of Overall Assignment
- to practice using procedural dataflow design techniques
- to consider software development as a process beyond implementation
- to think about the Gift problem before you develop it
- to practice developing software using good development techniques
- to explore resources and find answers to implementation details on your own

Overview
Your software development skills may be rusty. Consider this project a review. The program is not difficult. Don't make it harder than it is.

The gift program is a simplified version of on-line shopping where a user chooses items from an inventory and those items are added to a gift basket they might send to someone else. It is simplified so that we can apply the techniques we're studying without developing a huge program. I have cut out many aspects of the problem; for example, there is no way to remove an item from the basket, no payment or name information is gathered, and there is only one user filling one basket. You might wish to add features, but don't allow any additions to alter the order and effect of input. I have to be able to test your program automatically.

We might enhance this program later in the term. Therefore, remember to separate concerns and localize details of representation. All aspects of the problem will be fair game for modification. Plan accordingly. Use plenty of functions and pass information through parameters.

Gift Specification
This version of the problem has only one shopper. The inventory list is in a file whose name is given on the command line when the program is invoked. Each item in the list has a price followed by an item description. There are an unlimited number of items in the list, and for each item, you may assume an unlimited supply. For my testing, you need to keep the inventory list in the same order as in the file. Therefore, the first item in the file has item number 0, the second has item number 1, and so forth.

The user will build their gift basket's contents by adding items one at a time, sometimes printing the basket contents, sometimes asking for a list of item choices, and eventually checking out.

The user starts with an empty basket. There are three action choices repeated until the user chooses to check out. The user makes a choice by typing a letter and pressing return. Your program should treat upper and lower case as equivalent. The user might see the choices as a short menu:
   print (I)nventory, (A)dd item to basket, print (B)asket, (C)heckout-quit
   Action choice?
user would type letter of action choice here and press return

The I and B choices print the contents of the inventory or the basket. That output should be numbered starting at zero, labeled, and neat as well as accurate.

The C choice will stop the shopping, print a receipt, and cause the program to stop. The receipt should list the basket contents including description and price of each item, the total number of items, and the total price of the order.

The A choice will ask for an item number corresponding to items in the inventory. If the user enters a valid item number, that item is added to the basket. If the user enters an invalid item number, an error message is printed. The user might so foolish as to enter a non-numeric character. Do not give user another chance; treat that character as an invalid item number. You can use a nextLine() call to flush the rest of the input line.

After any action is completed, the next input should be an action choice. Any input other than a valid action choice should result in an error message and a reminder of the valid action choices. You may choose whether or not to show the action choices every time through this event loop.

Input and Output Specification
Input will be from a file with the file's name provided on the command line. The file will contain the items in the inventory with one line for each item. Each item will have a price expressed as a non-negative floating point number less than 1000. If an input value is out of that range, set the price of that item to 1. Each item's price is followed by a space and a text description up to 40 characters long. The text may include spaces and is terminated by the end of the line. Any excess text beyond 40 characters should be ignored through the end of line.

When the program starts, give a brief greeting or explanation, list the inventory, and provide a list of available actions. The remainder of the output should be in response to the user's commands. When printing the contents of some container, list the item number, the description, and the price. You do not need to show dollar signs but should show exactly two digits after the decimal point. Line up the descriptions on the left and the prices on the right. As an example, consider this order receipt:

Thank you for your order. Your order contains: 
                 Order Item Description           Price
     -----------------------------------------   -------
  0  One pound dark chocolate Wilbur Buds          6.99
  1  Text description with exact length of 40      0.42
  2  Lord of the Rings: Two Towers DVD            18.99
  3  One pound dark chocolate Wilbur Buds          6.99

There are 4 items. Your total cost is $33.39.