Homework #2


Problem 1 (30 points)

Assume the following requirements: "Packets are sent from one location to another. Packets have a certain weight. Locations are characterized by their transportation facilities, e.g. railway stations, airports and highway connections. Some locations are neighbored, i.e. there exists a direct transportation route between these locations. The transportation route between the locations has a certain length, i.e. the distance between the locations. Planes, trains, and trucks are used for transportation; each plane / train / truck may load a maximum packet weight. For each packet we want to know where it is, i.e. at which location or transport (plane, train, truck)."

(i) Draw a class diagram for the vending machine; identify the semantic relationships and cardinalities.

(ii) Draw the sequence diagram corresponding to a packet being sent from one location to another.

(iii) Draw a state transition diagram for this problem.


Problem 2 (20 points)

Given the following UML write the corresponding Ruby code.


Problem 3 (30 points)

In this problem you'll get to write a little bit of JavaScript code. For simplicity, take the problem described in HW-1 and produce a JS implementation.

Notes:

  • Your code will be tested using Spidermonkey, running in the standard test environment for this class.
  • There is no main() in JS, code gets interpreted line by line
  • The requirement for unit-testing is waived for this problem; this is to spare you the need to learn a new unit-testing framework. However, you get 10 points of extra credit for this assignment is you do provide unit-testing.

Important: Don't forget to re-read the syllabus to make sure you understand all the deliverables for assignments in this class, including this one.



$Id: hw2.html,v 1.1 2014/08/31 19:17:10 virgil Exp $