Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public class Circle extends Shape { private double radius; private Point center;

ID: 3694173 • Letter: P

Question

public class Circle extends Shape {

   private double radius;

   private Point center;

   public Circle(Point center, double radius) {

      this.radius = radius;

      this.center = center;

   }

   @Override

   public double computeArea() {

      return (Math.PI * Math.pow(radius, 2));

   }

}

Extend this so that there is a concrete extension of Shape that contains the following public methods:

void moveCenter(Point P): changes the center to point P, radius remains unchanged

void changeRadius (double r): changes the value of the radius to r

Explanation / Answer

public class Circle extends Shape {

private double radius;
private Point center;

public Circle(Point center, double radius) {
this.radius = radius;
this.center = center;
}

@Override
public double computeArea() {
return (Math.PI * Math.pow(radius, 2));
}
public void moveCenter(Point P)
{
       this.center = P;
}
public void changeRadius (double r)
{
       this.radius=r;
}
}