Você está na página 1de 4

Spring 2012

Allen Briscoe-Smith CALIFORNIA STATE UNIVERSITY, SACRAMENTO College of Business Administration MIS 120 Advanced OO Business Programming Programming Assignment #2

Points: 60 WHAT TO TURN IN All homework assignments are to be submitted via email (briscoe-smith@csus.edu) by noon on the due date. Make sure to ZIP up your entire project folder. NO LATE SUBMISSIONS FOR ASSIGNMENTS WILL BE ACCEPTED. NOTE: There are two parts to this assignment! Your solution will have two projects You will email me one ZIP file.

Part 1: Accounts Dictionary (20 points)


Create an application that lists accounts from a Dictionary object. Create an Account class that contains an ID, name, and balance. Display the accounts in a ListBox, as shown in Figure 1. If the user enters new values, she or he can click on the Add button to add a new account to the dictionary. Or if the user clicks the Replace button, she or he can replace a dictionary item. Use exception handlers to catch errors caused by invalid input values, or an attempt to add a duplicate Account ID to the dictionary. Figure 1 Adding an Account to the dictionary

Part 2: FirstPlay Sports Rental (40 points)


Create an application named FirstPlay Sports Rental that keeps track of the inventory for a sports rental store. Requirements Specification The user can input a new rental item and add it to the store inventory. The user can select an items ID Number from a list and remove the item from the inventory. The user can select an items ID Number from a list and display the items properties. When the application starts, it reads an inventory list from a file (text format). When the application ends, it writes the inventory list back to the same file.

User Interface Details Display a single sports rental item in a window, as shown in Figure 2. Each item has an ID number; a description; daily, weekly, and monthly rental rates; and the quantity on hand. When the application starts, it reads all item information from a file into a col-lection (implemented as a Dictionary) and copies the item ID numbers into a combo box on the form. The user can select an ID number from the combo box, and display or remove existing items. The user can also add new items to the collection. When the pro-gram ends, it writes the collection to the same file. Figure 2 Preparing to add a new item

Startup Form The applications startup form displays inventory items and lets users carry out each of the following actions: Input fields for a new rental item, and add that item to the inventory. Select an items ID Number and remove the item from the inventory. Select an items ID Number and display the items properties. When the form loads, the combo box should contain a list of all inventory ID Numbers. Returning to Figure 2 for a moment, we see that it shows a new item about to be added to the store inventory. When the Add Current Item button is clicked, the buttons handler creates a new Item object and passes it to the class that handles the store inventory. Figure 3 shows an example of searching for an item by ID Number. When the user clicks the DisplayItem button, the remaining item fields are filled in. When the user clicks the Remove Current Item button, the program confirms the operation with the user, as shown in Figure 4. If the answer is yes, the program removes the item identified by the ID Number.

Figure 3 Searching for an item selected by ID Number

Figure 4 Confirm before removing an item

Classes We suggest that the application define three classes: Item, Inventory, and InventoryFile. The Item class encapsulates a single inventory item. The Inventory class represents a collection that contains all items and provides methods for adding, finding, and removing items. Internally, it should hold the items in a Dictionary object. The InventoryFile class is responsible for reading the inventory data from a text file, and writing all Inventory data back to the file.

Example Text file Here is an example of what your text file will look like: LK00260 Tri-Fin Surfboard, high-performance 45 250 600 5 AB00300 Downhill Snow Skis 35 225 550 10 MN10040 Ocean Kayak, solo 60 250 750 4

Você também pode gostar