blue.shapes
Class Square

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

public class Square
extends java.lang.Object
implements Shape

A 'square' is modeled in terms of its side length, a real number.


Constructor Summary
Square(double s)
          Create a square.
 
Method Summary
 double area()
          Returns the area of this square.
 Circle circumscribingCircle()
          Return the smallest circle which bounds this square.
 void describe()
          Write a description of this square to the standard output file.
 void describe(OutStream os)
          Write a description of this square to the given OutStream.
 void describe(java.io.PrintStream ps)
          Write a description of this square to the given PrintStream.
 double diagonal()
          Returns the diagonal of this square.
 void expand(double d)
          Expand this square by augmenting its side by the given number.
 Circle inscribingCircle()
          Return the largest circle which is bounded by this square.
 double perimeter()
          Returns the perimeter of this square.
 void shrink(double d)
          Shrink this square by diminishing its side by the given number.
 double side()
          Returns the side length of this square.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Square

public Square(double s)
Create a square.
Parameters:
s - the side length of the square
Method Detail

side

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

diagonal

public double diagonal()
Returns the diagonal of this square.

area

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

describe

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

describe

public void describe(java.io.PrintStream ps)
Write a description of this square 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 square to the given OutStream.
Specified by:
describe in interface Shape
Parameters:
os - the stream to which the description is written

perimeter

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

expand

public void expand(double d)
Expand this square by augmenting its side by the given number.
Parameters:
a - amount by which the square is expanded

shrink

public void shrink(double d)
Shrink this square by diminishing its side by the given number.
Parameters:
a - amount by which the square is contracted

inscribingCircle

public Circle inscribingCircle()
Return the largest circle which is bounded by this square.

circumscribingCircle

public Circle circumscribingCircle()
Return the smallest circle which bounds this square.