CS 432

Midterm 1

Due 2/11/2008 before 4PM

 

This is a test and as such you are not to discuss any part of it with anybody except the instructor. I am in the phone book and you may call me to seek clarifications (at reasonable times). Read the following declaration and sign after you have completed the test.

 

I have neither given nor received aid.

 

Name and signature:

 

For this test you will implement a shopping cart as described (for the northwind database). Sample code for implementing shopping carts is given on the class homepage.

a.      Create an object CartItem with attributes Id, Name, Price, and Qty. This will be used to hold an item that the user adds to a cart. Add appropriate properties and methods.

b.     On the user interface, show your products in a dropdownlist control. Show a text box (for users to enter a quantity) and a button to ‘Add to Cart’. You will also need a button to ‘Checkout’ the items.

c.     A user will select an item, fill in the quantity and click the AddtoCart button. At this point, create an instance of the CartItem object and add it to an arraylist (called the ShoppingCart). You will need to access the database to get the price of the item chosen. Sample code to do this (getPrice.aspx) is also given on the class homepage. User session variables to retain the items selected.

d.     When the user is done, they will click ‘Checkout’. At this point, you have to print for the user the number of items in the cart and the total for the purchase.

 

Graduate Students

Instead of using an arraylist, use hashtable and dictionary objects to store the CartItems (one implementation using the hashtable and one using the dictionary). What advantages do these collection objects offer over an arraylist?