Fill in the code in the following program.
Area of a circle is pi * r2.
public class Circle {
/** The radius of the circle */
private double radius = 1;
/** The number of the objects created */
private static int numberOfObjects = 0;
/** Construct a circle with radius 1 */
public Circle() {
numberOfObjects++;
}
/** Construct a circle with a specified radius */
public Circle(double newRadius) {
radius = newRadius;
_______________________;
}
/** Return radius */
public double getRadius() {
return radius;
}
/** Set a new radius */
public void setRadius(double newRadius) {
radius = (newRadius >= 0) ? newRadius : 0;
}
/** Return numberOfObjects */
public static int getNumberOfObjects() {
_______________________;
}
/** Return the area of this circle */
public double getArea() {
_______________________________;
}
}



Answer :

Other Questions