This website is preserved for historical and scholarly reference and is no longer actively maintained.
CpSc 210, Section 1
Assignment 3
February 14, 2001
Due: Thursday, February 22 by 11:59 p.m.
Assignment: Complete the Triangle class given in pages 228-233
of Java Elements. In addition to the methods listed in the
Drawable interface (page 228), include
public Object clone ();
// post: Returns a field-for-field copy of this.
public boolean equals ( Triangle other );
// pre: other is a valid Triangle
// post: Returns true if there is a 1-1 correspondence between
// vertices. The order of the points may be different.
public String toString ( );
// post: Returns a String representation of the Triangle
If you are not sure what a method should do, check what the corresponding
method does in the Rect class.
Late penalties: 20 points per partial day late. That is, programs
turned in after 11:59 p.m Thursday and before 11:59 p.m. Friday
will have 20 points deducted for late. Programs will not be
be accepted after 11:59 p.m. Friday, February 23.
Total point value of assignment: 100 points plus extra credit
This assignment is to be done INDIVIDUALLY.
Create a directory, A3, which will contain all parts of this assignment.
(In this assignment the directory A3 will contain a single file
named Triangle.java. )
The primary objective of this program is to give you practice with the
design and implementation of a class for the drawing window. We may
later talk about a more general class, the Ngon.
Other requirements:
Follow the style standards to be found on your instructor's
web page for CPSC 210.
Submit your program using the handin command. There is a link to
the handin description on your lab page (www.cs.clemson.edu/~lab210).
Grading rubric:
In the opinion of the instructor the program is an honest attempt
to complete the assignment as described 10 points.
If the above requirement is met and required documentation and
style standards are used. 10 points.
The previous requirements are substantially met and the program compiles
without error. 10 points.
The following points are available only to programs that
compile without error: Methods will be tested in the order
given. If any method causes program termination, no further
testing will be done.
The methods width(), right(), bottom(), and top() are worth
5 points each for a total of 20 points.
The methods clone(), equals, and toString() are worth 10 points
each for a total of 30 points.
The main method should check all the other methods for correctness.
It should check every method at least once and print a message
if an error is detected. The main method should also write a
message if all methods work correctly. Comments should describe
the testing clearly. Quality of test program: 20 pts.
Thus, this programming assignment is worth a total of 100 points.
Extra credit: The fillOn method in the text is "fudged" --
that is, code is inserted but the method does not fill a triangle.
If the above 100 points have been satisfied (within a point or two)
you may attempt extra credit for fillOn: 10 points if fillOn
fills the triangle. An additional 10 points if fillOn works
correctly with invertMode().