/* Circle is a class representing the mathematical concept of circle. This class includes the following operations:

This class is written for the Java tutorials of SE2AA4 (Winter 07). @author Clare So */ public class Circle { private double diameter; // The diameter of the circle /** The diameter of the circle is 10cm by default. */ public Circle() { diameter = 10.0; } /** The circle can be initialized of other sizes. @param d diameter of the new circle */ public Circle(double d) { diameter = d; } /** Make the circle bigger @param factor Centimetres to be added to the diameter @return updated diameter */ public double grow(double factor) { diameter = diameter + factor; return diameter; } /** Make the circle smaller @param factor Centimetres to be subtracted from the diameter @return updated diameter */ public double shrink(double factor) { diameter = diameter - factor; return diameter; } /** Return the diameter of the circle @return current diameter */ public double getDiameter() { return diameter; } /** Calculate the circumference of the circle @return circumference of the circle */ public double calculatetCircumference() { double PI = 3.14; return diameter*PI; } /** Report the diameter of the circle by a string @return a sentence reporting the diameter of the circle */ public String toString() { return "The diameter of this circle is " + diameter + " cm."; } }