blue.shapes
Class Triangle

java.lang.Object
  |
  +--blue.shapes.Triangle

public class Triangle
extends java.lang.Object
implements Shape

A 'triangle' is modeled in terms of its three sides, sideA, sideB, and sideC.


Constructor Summary
Triangle(double d)
          Create an equilateral triangle.
Triangle(double same, double diff)
          Create an isosceles triangle.
Triangle(double a, double b, double c)
          Create an irregular triangle.
 
Method Summary
 double area()
          Returns the area of this triangle.
 void describe()
          Describes this triangle in terms of its properties.
 void describe(OutStream os)
          Describes this triangle in terms of its properties, writing the description to a OutStream.
 void describe(java.io.PrintStream ps)
          Describes this triangle in terms of its properties, writing the description to a PrintStream.
 double perimeter()
          Returns the perimeter of this triangle.
 double sideA()
          Returns the sideA of the triangle.
 double sideB()
          Returns the sideB of the triangle.
 double sideC()
          Returns the sideC of the triangle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Triangle

public Triangle(double d)
Create an equilateral triangle.
Parameters:
d - the length of each side.

Triangle

public Triangle(double same,
                double diff)
Create an isosceles triangle.
Parameters:
same - the length of two of the sides.
diff - the length of the "odd" side.

Triangle

public Triangle(double a,
                double b,
                double c)
Create an irregular triangle.
Parameters:
a - the length of sideA.
b - the length of sideB.
c - the length of sideC.
Method Detail

sideA

public double sideA()
Returns the sideA of the triangle.

sideB

public double sideB()
Returns the sideB of the triangle.

sideC

public double sideC()
Returns the sideC of the triangle.

area

public double area()
Returns the area of this triangle.
Specified by:
area in interface Shape

perimeter

public double perimeter()
Returns the perimeter of this triangle.

describe

public void describe()
Describes this triangle in terms of its properties.
Specified by:
describe in interface Shape

describe

public void describe(java.io.PrintStream ps)
Describes this triangle in terms of its properties, writing the description to a PrintStream.
Specified by:
describe in interface Shape
Parameters:
ps - the PrintStream on which the description is written.

describe

public void describe(OutStream os)
Describes this triangle in terms of its properties, writing the description to a OutStream.
Specified by:
describe in interface Shape
Parameters:
os - the PrintStream on which the description is written.