Question: Circle.java A simple class which models a circle by its one defining characteristic, which is its radius. This class is moderately complete and must be

Circle.java A simple class which models a circle by its one defining characteristic, which is its radius. This class is moderately complete and must be modified as such: 1. Both the default and copy constructors simply call the specifying constructor, with the appropriate argument

2. Include a class constant for PI Whose value is the best approximation of PI you can store ( public or private? static or not? final or not? )

3. Include an instance constant for units Whose default value is cm ( public or private? static or not? final or not? )

4. The print() method is modified to include the units the radius is given in

5. Include an overloaded 0-arity mutator for the radius value that sets the radius value to 0 ( where is the one and only place it make sense to call this?

6. Include an area method that returns the area of the circle in units squared My code so far for Circle.Java:

public class Circle { private static int instanceCnt = 0; private double radius;

public static int getInstanceCnt() { return Circle.instanceCnt; }

private static void setInstanceCnt(int insCnt) { Circle.instanceCnt = insCnt; }

public Circle() { }

public Circle(double newRadius) { Circle.setInstanceCnt(Circle.getInstanceCnt() + 1); this.setRadius(newRadius); }

public Circle(Circle guest) { }

public double getRadius() { return this.radius; }

private void setRadius(double radius) { if (radius >= 0) this.radius = radius; else this.radius = 0; }

public void resize(double newRadius) { this.setRadius(newRadius); }

public Circle clone() { return new Circle(this.getRadius()); }

public boolean equals(Circle guest) { return guest.getRadius() == this.getRadius(); } public void print() { System.out.print("The circle\'s radius is " + this.getRadius()); } }

CircleDriver.java A simple driver class to test your additions to the Circle class. This class you are writing from scratch, but must include sufficient code to test all of the new features listed above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!