Class MutableCircle

java.lang.Object
  extended by MutableCircle

public class MutableCircle
extends java.lang.Object


Field Summary
static double PI
          Contains the value of pi to four decimal places.
 
Constructor Summary
MutableCircle()
          Creates a circle at the origin with radius 1.
MutableCircle(double x, double y, double radius)
          Creates a circle with center at the given x-y position, with the given radius.
MutableCircle(MutableCircle otherCircle)
          Copy constructor: Creates a copy of the given circle.
 
Method Summary
static double area(double radius)
          Calculates the area of a circle with the given radius.
static double circum(double radius)
          Calculates the circumference of a circle with the given radius.
 boolean equals(java.lang.Object obj)
          Determines whether this circle is equal to a provided object.
 double getRadius()
          Returns the radius of the circle.
 double getX()
          Returns the X coordinate of the circle's center.
 double getY()
          Returns the Y coordinate of the circle's center.
static int numCircles()
          Returns the number of circle objects that have been created.
 boolean overlap(MutableCircle otherCircle)
          Determines whether this circle overlaps with another given circle.
 double setRadius(double radius)
          Sets a new radius.
 java.lang.String toString()
          Converts the object to a string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PI

public static final double PI
Contains the value of pi to four decimal places.

See Also:
Constant Field Values
Constructor Detail

MutableCircle

public MutableCircle(double x,
                     double y,
                     double radius)
Creates a circle with center at the given x-y position, with the given radius.

Parameters:
x - X coordinate of the circle's center
y - Y coordinate of the circle's center
radius - Radius of the circle

MutableCircle

public MutableCircle(MutableCircle otherCircle)
Copy constructor: Creates a copy of the given circle.

Parameters:
otherCircle - Circle to be copied.

MutableCircle

public MutableCircle()
Creates a circle at the origin with radius 1.

Method Detail

area

public static double area(double radius)
Calculates the area of a circle with the given radius.

Parameters:
radius - Radius of the circle.
Returns:
Area of the circle.

circum

public static double circum(double radius)
Calculates the circumference of a circle with the given radius.

Parameters:
radius - Radius of the circle.
Returns:
Circumference of the circle.

getX

public double getX()
Returns the X coordinate of the circle's center.

Returns:
X coordinate of the circle's center.

getY

public double getY()
Returns the Y coordinate of the circle's center.

Returns:
Y coordinate of the circle's center.

getRadius

public double getRadius()
Returns the radius of the circle.

Returns:
Radius of the circle.

setRadius

public double setRadius(double radius)
Sets a new radius. If radius >= 0, sets the radius; if radius < 0, leaves the radius unchanged. Returns the ultimate value of the radius.

Parameters:
radius - New radius.
Returns:
Resulting value of the radius.

overlap

public boolean overlap(MutableCircle otherCircle)
Determines whether this circle overlaps with another given circle.

Parameters:
otherCircle - Other circle for comparison of overlap.
Returns:
True if they overlap, false otherwise

toString

public java.lang.String toString()
Converts the object to a string. For example, for a circle with center at x = 1, y = -1, and radius 5, this method returns the following string: "Circle:x=1,y=-1,radius=5".

Overrides:
toString in class java.lang.Object
Returns:
String representation of the object.

equals

public boolean equals(java.lang.Object obj)
Determines whether this circle is equal to a provided object. Two circles are equal if they have the same center and radius.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to be compared for equality
Returns:
True if equal, false otherwise

numCircles

public static int numCircles()
Returns the number of circle objects that have been created.

Returns:
Number of created circles.