CSCI 221
Assigned Date: Wednesday, January 19, 2005 (sec 2 +1 day)
Due Date: Wednesday, February 2, 2005 (sec 2 +1 day)
Due Time: Noon


Updated: Wednesday, January 26, 2005, 1:30 p.m.



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.” [1] 

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.>


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.  There are several ways to do this.  Look for the most elegant one.

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.  Add your name, date, course, etc. info.  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

o       doc subdirectory with .html API files, one for each of your classes (e.g., Shape.html, etc.).  These files contain the javadoc documentation generated from your source files when you press <Ctrl>-J within the BlueJ source-code editor window.



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