Tuesday, April 27, 2010

SOFT6008 Assessment 2


Following discussions with the class we have opted for an out-of-class exercise rather than an in-class one. Students should be aware that my internal plagiarism threshold has been turned to its most sensitive setting. Students are not permitted to swap code.
The code you need is in files called cart0.html and cart1.html
When working it should look something like this

The code you have been provided with is a partial implementation of a shopping cart using JavaScript. The cart is stored as a long string in a cookie called "shoppingcart". ## is used to separate each item from the next. The data fields for each item (ID, Name, quantity, unit cost) are separated by #.



From the table display of the cart on cart1.html it should be possible for items to be added, subtracted, and deleted from the shopping cart. However the code is incomplete and only add has been implemented.


This implementation is somewhat old-fashioned because it does not used the JavaScript to modify the appearance of the page using the DOM after it has been written. Instead any change to a value causes the cart to be written to the cookie and the page reloaded. The page is reloaded by window.location.reload()


One uncommon feature of the code it that the JavaScript, in addition to outputting HTML also outputs some JavaScript. This is how the onclick method is passed the correct parameter. The parameter is written when the table is displayed.



Complete the code so that:
1. The price is displayed. A place holder for this code has already been provided. So you just need to write the function.
2. The price is displayed in Euro and not cent. (19.99 and not 1999). You should implement this with the aid of a function. (The video outlining the functionality of the code does not show this.)


3. The total cost of the items in the cart is displayed (ideally in an additional row of the table in the price column)
.

4. Items can be subtracted from the cart. If the number of copies of an item is zero it should not appear at all.


5. Items can be removed from the cart entirely.

6. If the cart is empty the text "Shopping Cart Empty" is displayed instead of the table. (The video outlining the functionality of the code does not show this.)



You may modify the code in any way you see fit. However all of these features can be added by adding code. You need not delete any existing code.

Submission details:
Students should rename cart0 and cart1 to so that they include their names. e.g dandeman0.html dandeman1.html
These files and the associated images should be archived into a zip file and emailed to Colin. Alternatively it can be submitted in plain text on a CD or USB stick.

The deadline is 1700 Tuesday 4 may.

No comments: