blue.shapes
Class Polygon

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

public class Polygon
extends java.lang.Object
implements Shape

A 'regular polygon' is modeled in terms of its degree (number of sides) and its side length.


Constructor Summary
Polygon(int d, double s)
          Create a polygon.
 
Method Summary
 double area()
          Return the area of this polygon.
 Circle circumscribingCircle()
          Return the circumscribing circle of this polygon.
 void dec()
          Transform this polygon to a polygon of one less degree.
 void decSide()
          Subtract one from the length of the sides of this polygon.
 int degree()
          Returns the degree of this polygon.
 void describe()
          Write a description of this perimeter to the standard output file.
 void describe(OutStream os)
          Write a description of this polygon to the given OutStream.
 void describe(java.io.PrintStream ps)
          Write a description of this polygon to the given PrintStream.
 void inc()
          Transform this polygon to a polygon of one additional degree.
 void incSide()
          Add one to the length of the sides of this polygon.
 Circle inscribingCircle()
          Return the inscribing circle of this polygon.
 double perimeter()
          Return the perimeter of this polygon.
 void resize(int s)
          Resize this polygon by changing the lengths of each side.
 double side()
          Returns the side length of this polygon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Polygon

public Polygon(int d,
               double s)
Create a polygon.
Parameters:
d - the degree of the polygon.
s - side length of the polygon.
Method Detail

degree

public int degree()
Returns the degree of this polygon.

side

public double side()
Returns the side length of this polygon.

inc

public void inc()
Transform this polygon to a polygon of one additional degree. "Morph it up".

dec

public void dec()
Transform this polygon to a polygon of one less degree. "Morph it down".

resize

public void resize(int s)
Resize this polygon by changing the lengths of each side.
Parameters:
s - the new side length of this polygon.

incSide

public void incSide()
Add one to the length of the sides of this polygon.

decSide

public void decSide()
Subtract one from the length of the sides of this polygon.

area

public double area()
Return the area of this polygon.
Specified by:
area in interface Shape

perimeter

public double perimeter()
Return the perimeter of this polygon.

describe

public void describe()
Write a description of this perimeter to the standard output file.
Specified by:
describe in interface Shape

describe

public void describe(java.io.PrintStream ps)
Write a description of this polygon to the given PrintStream.
Specified by:
describe in interface Shape
Parameters:
ps - the stream to which the description is written

describe

public void describe(OutStream os)
Write a description of this polygon to the given OutStream.
Specified by:
describe in interface Shape
Parameters:
os - the stream to which the description is written

circumscribingCircle

public Circle circumscribingCircle()
Return the circumscribing circle of this polygon.

inscribingCircle

public Circle inscribingCircle()
Return the inscribing circle of this polygon.