Take Home Exam
NOTES: (Please read these carefully!)
(i) Clearly mark at the top of each sheet you use: (a) your name (b) your e-mail address (in case I need to contact you) (c) the page number.
(ii) On the front page indicate how many pages are contained in your work in total.
(iii) Your work must be handed in to NADAs studentexpedition no later than Wednesday 1st June 2005 at 11.00 am. After this time it will be marked as late, and marks will be subtracted.
(iv) If you have any questions about the exam (for example, if you do not understand a question) you may call my mobile number 076 223 86 79. Please do not call before 9.00 am or after 9.30pm!
(v) You may use your kursbunt, and any course books. You are allowed to use the internet including search engines. However, any work which you download and use must be credited to its source. You are not allowed to discuss or develop your answer with anyone else before all manuscripts have been handed in. You are not allowed to copy anyone else's work. By handing in your manuscript you are declaring that you have abided by these rules. In the case that cheating is suspected, actions will be taken against any students involved.
(vii) Write clearly. No marks will be awarded for work that I cannot read. You can write your answers in swedish or english.
Answer all questions. Maximum marks are 50 points. A grade 3 will be awarded for 25 points or more, grade 4 is awarded for 30 points or more, grade 5 is awarded for 35 points or more.
Question 1 . You are asked by your boyfriend/girlfriend to design and build a simple internet shopping site for books, clothes and DVDs.
(i) (4 points) He/she brainstorms and identifies the following nouns: book, clothing, dvd, size, clothing_style, author, title, artist, colour, mens_clothing, womens_clothing, childs_clothing, price, quantity, discount_on_price, item. Arrange these into a UML class diagram.
(ii) (4 points) You decide to implement a traditional shopping cart user model. The essential component of the cart is a List_of_Item class which is recursively defined in terms of a class Item. You identify the need to construct 0-element and 1-element lists, to add and delete a specific item, and to delete a list. From this class you can build a Shopping_Cart class which also includes the total price of all purchases, the total number of all purchases and the total discount offered on purchases. Discount on price is given only to club members on the web site. A shopper can be a member of the book club, the dvd club or the clothing club separately. Working with the shopping cart, an online user can add or delete specific items and either checkout the purchases or delete the entire cart.
Extend your class diagram of part (i) to include this information.
(iii) (2 points) A shopper needs to be a member of the book club to get discounts on books, dvd club for dvds etc. Using the information given in you class diagram for (i) and (ii) write code for the method add(Item purchase) that adds an Item to a List_of_Item and applies the correct discount to the price if appropriate.
Question 2. Now you want to demonstrate to your boyfriend/girlfriend how the site will work. You want to describe a typical shopping scenario where a shopper starts shopping by buying 1 item and then adds and deletes new items until either they are satisfied and checkout, or suddenly realise they can't afford anything and delete the shopping cart.
(i) (4 points) Write a text use case for this scenario, including careful descriptions of pre and postconditions.
(ii) (6 points) Then draw a UML sequence diagram which models this use case exactly. Be careful to model any activities which can be repetetive or contain alternatives.
Question 3. (10 points) Your boyfriend/girlfriend takes your UML designs to the bank. They understand nothing, but are extremely impressed by both your professionalism. They decide to lend you money to finance the project. However, they want to know how you will use the money. Explain how a software lifecycle model can answer their question. What lifecycle models might be best for a project of this type?
Question 4. (5 points) You decide to use the XP software lifecycle model, which means you must write tests first. Write JUnit tests for the Shopping_Cart class that test the functionality of add(Item purchase) and delete(Item purchase). Your tests should also check that any relevant attributes of the class are updated correctly.
Question 5. (10 points) You decide to store and send information from the website using the XML format. Write a DTD that is suitable for defining an XML file that represents the contents of a shopping cart. Write a short XML file that models the contents of one possible shopping cart and is a valid instance of your DTD.
Question 6. (5 points) The site is now up and running. However, whenever your boyfriend/girlfriend logs on to the webserver to update price and discount information, customers who are currently online start to phone in and complain that the cost of their orders is incorrect. Explain what is most likely to have gone wrong. How would you use Java technology to solve the problem? Describe specific changes that you would make to specific software components (classes, methods etc.)