CSCI 221
Assigned Date: Wednesday, September 1, 2004
Due Date: Friday, September 10, 2004
Due Time: Noon

Updated: Monday, September 6, 2004, 8:23 AM.



“A dollop of variables and a dash of comments are proper ingredients, but good programming (like good cooking) takes talent that doesn’t come with the cookbook.  Instructors at restaurant schools realize this, and begin their courses by teaching prospective chefs the Zen of boiling water or breaking eggs.” [1] Approach this assignment in this frame of mind.



This assignment focuses on Java inheritance, polymorphism, abstract classes, and interfaces.  It also gives you an opportunity to get comfortable with BlueJ. 



All programs that you complete in your career as a student and as a professional developer should be fully documented.  Follow the Golden Rule of Style: “A program should be as easy for a human being to read and understand as it is for a computer to execute.” [2] 

Your comments should be in the Javadoc style.

You should always include opening comments that state the author of the file, the date, documentation of resources used to write the code, and comments related to the code and its functionality.  This semester your opening comment section for every source file you submit should have the following format.   


 *  Author:     <Your Name>
 *  Email:      <Your email address> 
 *  Class:      CSCI 221, Section <Your section number> 
 *  Assignment: HMWK1
 *  Due Date:   <The assignment's due date>
 *  Certification of Authenticity <include one of the following>:     
 *     I certify that this work is entirely my own.
 *     I certify that this work is my own, but I received
 *     some assistance from:  <Name(s), References, etc.>
 *  Purpose: <Provide a simple, yet complete description of the task being
 *       performed by this class. It may be several sentences long.>
 *  Input: <Provide a simple, yet complete description of the input required
 *              by this class, if any.>
 *  Output: <Provide a simple, yet complete description of the output generated
 *              by this class, if any.>


Assignment:  (adapted from [3])

Expand the Shape class hierarchy to include a class for equilateral triangles and a class for isosceles triangles (i.e.,, and  For a review of such triangles, see triangle formulas.  Modify the Triangle class (i.e., to model scalene triangles – triangles with three, possibly unequal sides.

Modify the Shape class and its subclasses to implement the Relation interface.  The Relation interface methods should compare the areas of individual shapes.

Write a test program ( that creates a series of shapes and sorts the shapes into ascending order of size using the SortObj.sort() method.

Capture a screenshot of the BlueJ window displaying your class hierarchy (positioned just right!).  For instance, on MS Windows, press <Alt>-<PrintScreen>, open MSWord or Wordpad, and paste the screenshot by pressing <Ctrl>-V.  Save the document as ClassDiagram.doc . 



You should submit your source file on a floppy disk, as per syllabus instructions. 

Source filenames to be submitted: 

A zip archive named <firstName_lastName_fourLastDigitsofSSN> (for example,  This archive should contain the following files:

·        Shape (the BlueJ project directory).  Within Shape there should be the following files:

o       Readme.txt (see Widget for a sample)

o       Any files generated automatically by BlueJ (e.g., bluej.pkg, bluej.pkh, etc.)

o,,,,,,,,,, and

o       ClassDiagram.doc



  1. Cooper, D. and Clancy, M. (1985) “Oh! Pascal”, 2nd ed., W.W. Norton & Company, New York, p. 41.
  2. ibid., p. 42.
  3. Chapman, S.J. (1999) “JAVA for Engineers and Scientists”, 1st ed., Prentice Hall, New Jersey, p. 316.