Question: Write a class encapsulating the concept of a circle, a circle has the following attributes: a Point representing the center of the Circle, and a

Write a class encapsulating the concept of a circle, a circle has the following attributes: a Point representing the center of the Circle, and a none negative number-the radius of the circle. Include constructor, the accessors and mutators, perimeter, area methods, and overwrite toString methods. Here are the outline of the classes you need to define: Circle (the class name must be named as Circle.java): data member: center (Point type), radius (double) constructor: takes two parameter (Point center, double radius) and the no parameter constructor which sets its center to (1.0, 1.0) and radius to 1.0 a circle radius must be within the range (0, 25], otherwise set to its default radius (1.0) methods: all getter and setter methods perimeter returns the perimeter of the circle area return the area of the circle toString returns the circle information as follows: Radius: 1.00 Center[1.00, 1.00] Perimeter: 6.28 Area: 3.14 Point (must be named as Point.java): data member: x (double for x-axis) and y (double for y-axis) All getter and setter methods constructor: two parameters to set x and y, and a no parameter constructor with default value: x=0 and y=0; Overwrite toString method which returns the point information as follows: [1.00, 1.00] CircleTester(driver class to test your classes) 1. Create a java file named CircleTester.java 2. Open the file named CircleTester.txt, copy and paste the content to your CircleTester.java 3. Compile and run the CircleTester.java to test your Point and Circle classes If your Point and Circle classes are defined properly, the tester program should generate the following output:  Radius: 2.00 Center[0.00, 0.00] Perimeter: 12.57 Area: 12.57 Radius: 10.00 Center[-1.00, -10.00] Perimeter: 62.83 Area: 314.16 Radius: 1.00 Center[2.00, -1.00] Perimeter: 6.28 Area: 3.14 Radius: 1.00 Center[-1.00, -10.00] Perimeter: 6.28 Area: 3.14 Radius: 25.00 Center[0.00, 0.00] Perimeter: 157.08 Area: 1963.50 Radius: 1.00 Center[0.00, 0.00] Perimeter: 6.28 Area: 3.14  

CircleTester

public class CircleTester{

public static void main(String[] args){ Circle c1= new Circle(new Point(0, 0), 2); Circle c2= new Circle(new Point(-1,-10), 10); Circle c3= new Circle(new Point(2, -1), -5); System.out.println(c1); System.out.println(c2); System.out.println(c3);

c2.setRadius(0); System.out.println(c2);

c1.setRadius(25); System.out.println(c1);

c1.setRadius(25.05); System.out.println(c1); }

}

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!