Homework 1

Homework 1 involves answering questions related to the following set of figures.

Homework1

Figure 1: Feline Class Hierarchy

  1. Implement this model in two different object-oriented languages similar to what was shown in lecture 2 for the Airplane/Jet example. The function roam() should simply update the location of the animal any way you see fit. You can assume that the Point class has getter and setter methods for attributes x and y.
  2. Write a program that creates instances of Cat and Lion and interacts with them in some way. At least one part of your program, should store these instances into an array of type Feline and then interact with both Lions and Cats via the Feline interface.
  3. If we wanted to add a Hippo, Elephant, Dog, and Wolf to the simulation, we would want to update the UML model in some fashion (possibly adding additional classes than just these four). Create a diagram that shows the UML model updated in this way.

rectsquare

Figure 2: Rectangle-Square Hierarchies

The figure above contains two class diagrams showing different ways to arrange three classes: Shape, Rectangle, and Square.

  1. Describe what each diagram is asserting about the classes, i.e. what is it that you know about these classes based on the semantics of the UML notation. How are the semantics of these two diagrams similar to each other and how are they different?
  2. Now, imagine in the diagram on the left that the Rectangle class defines two attributes: width and height and defines getter and setter methods for these attributes in the standard way. The Square class cannot directly reuse all four of these methods. Why not? Does this have any implication on using inheritance between Rectangle and Square? Put another way, can using inheritance between these two classes cause any problems?
  3. Given your answer to the previous questions, discuss how the diagram on the right might address the problems and/or implications that you described in questions 4 and 5.

This assignment is due by 11:55 PM on Friday, September 11th. Please send a link to an archive that contains the source code for questions 1 and 2 (ensure that each directory has a README file that describes your program and provides instructions on how to compile/run it) a PDF file for question 3, and a PDF or text file containing your answers to questions 4, 5 & 6.

Once you have sent your link, Prof. Anderson or the grader, Chris Baker, will download your archive and send you mail to let you know that we have received it.

You are encouranged to work in teams on this assignment. You should submit only one archive per team and then include a document in your archive that clearly states which students worked on the answers contained in the archive.

Any questions? Send them to Prof. Anderson.

Grading Rubric


To achieve this grade: Rubric
A All questions answered correctly with high polish (no or little spelling/grammatical errors). Answers build on the examples contained in the figures or include examples of their own that are related to the figures in some way. Answers follow the formats specified in the problem statement and the submitted archive is well structured and easy to grade.
B All questions answered correctly with medium polish or with one or two questions wrong. Answers may not directly answer the questions asked but are close or answers are correct but no supporting context is provided.
C All questions answered correctly but with low polish or with three questions wrong. Answers are not clear/concise, provide very little supporting context, only tangentially reference the examples contained in the figures and have problems with grammar and spelling.
D The assignment was of low quality with the majority of answers missing or wrong. Answers are not polished, do not build on or reference the examples presented in the figures and contain problems with grammar and spelling.
F The assignment was either not submitted or was of extremely poor quality. Poor quality work would consist of almost all answers either missing or wrong or answers lacking detail, containing many grammatical/spelling errors, or not addressing the questions that were asked.
© Kenneth M. Anderson, 2009.