Homework 2

Homework 2 consists of answering the questions below. This homework is worth 30 points (5 points for the first two UML questions; 10 points for the third UML question; 5 points for the first short answer question; and 5 points for the last short answer question).

  1. 1. Draw a UML class diagram that models the following statements: “A is a subclass of B. A implements interface C which is used by D to access A. B is associated with one or more E's.”
  2. 2. Draw a UML class diagram that models the following statements: “CargoPlane aggregates zero or more Pallets. Each Pallet aggregates zero or more Boxes; CargoPlane is composed of one or more Parts. Inside each Box are one or more Items that are accessed by part number.”
  3. 3. Draw a UML class diagram that models the following statements: “A University is composed of one or more Units, such as Colleges and Schools. Each Unit contains faculty, students and staff. A unit maintains an address book filled with entries, one for each type of person contained in that unit. An entry can be located in the address book by supplying their last name or their university id. Faculty members can be the advisor of zero or more students.”
  4. 4. Answer the following question about the class diagram you created in question 1: “Can D access an instance of B via C's interface? Explain.”
  5. 5. Imagine we have a system that has a class called Shape and subclasses Square, Circle, and Triangle each developed by a different software engineer. The system uses these classes to create randomly generated visualizations that balance various constraints concerning the area and perimeter of each individual shape along with the total area and total perimeter of all shapes on the screen. (An example of such a constraint might be that the total area of all shapes must always be twice as large as the total perimeters.) One engineer, feeling capricious, decides to implement the getArea() method of the Square subclass by having it return the perimeter of the Square instead. What design heuristic presented in Lecture 5 and Lecture 2 about classes has this engineer violated and what repercussions will it have in the overall system?

Due Dates: Your submission will be a PDF file containing the answers for questions 1-5 which you will upload to the Moodle by 12:25 PM next Thursday, September 20th. In-class students, please bring a printout of your work to lecture that day.

NOTE: Please follow the naming guidelines specifed on the Assignments page when naming the file you upload to the Moodle.

Note: Any homework submitted after that time but by 12:25 PM on Thursday, September 27, 2012 will be graded but will receive a 15% penalty. After that, submissions of Homework 2 will be ignored.

As always, you are encouraged to work in teams on this assignment. If you do, you will submit just one assignment for the entire team; that assignment will list the names of the team members at the top of the first page of the submission.


© Ken Anderson 2012