abstract class GeometricObject
{
private String color = "white";
private boolean filled;
protected GeometricObject()
{ ... }
protected GeometricObject ( String color, boolean filled )
{ ... }
public String getColor()
{ ... }
public void setColor ( String color )
{ ... }
public boolean isFilled ()
{ ... }
public void setFilled ( boolean filled )
{ ... }
public abstract double findArea();
public abstract double findPerimeter();
}
You will then write a class Triangle that extends the GeometricObject class.
class Triangle extends GeometricObject
{
private double side1, side2, side3;
public Triangle ( double side1, double side2, double side3 )
{ ... }
public double findArea()
{ ... }
public double findPerimeter()
{ ... }
public String toString()
{ ... }
}
You will write a driver to test the Triangle class called TestTriangle.
public class TestTriangle
{
public static void main ( String[] args )
{
Triangle aTri = new Triangle ( 3.0, 4.0, 5.0 );
System.out.println ("Triangle A has sides: " + aTri );
System.out.println ("Area of Triangle A is " + ... );
System.out.println ("Perimeter of Triangle A is " + ... );
Triangle bTri = new Triangle ( 5.0, 12.0, 13.0 );
System.out.println ("Triangle B has sides: " + bTri );
System.out.println ("Area of Triangle B is " + ... );
System.out.println ("Perimeter of Triangle B is " + ... );
}
}
The file that you will be turning in will be called TestTriangle.java. You will follow the standard Java coding convention that I have appended below. The file will have a header of the following form:
/* File: TestTriangle.java Description: Student Name: Student UT EID: Course Name: CS 303E Unique Number: TA: Date Created: Date Last Modified: */
You will follow the standard Java Coding Conventions. You can either view the HTML page or download the PDF or Postscript and print it out. There is a modification that I would like to make to the standard coding conventions. Please align the opening and closing braces vertically so that you can easily make out the blocks of code.
Use the turnin program to submit your TestTriangle.java file. The TAs should receive your work by 5 PM, Friday, 30 April 2004.