Prompt: Write a class encapsulating the concept of a circle, assuming a circle has the following attributes: a Point representing the center of the circle, and the radius of the circle, and integer. Include a constructor, the accessors and mutators, and methods toString and equals. Also include methods returning the perimeter ( 2 × 𝜋 × 𝑟 ) and area ( 𝜋 × 𝑟^2) of the circle. Write a client (application) class to test all the methods in your class.
I started out trying to thing how to do this and I mapped out a certain idea but do not know how to incorporate the point represent the center of the circle. I am not sure how to proceed further.. Please give me your wise guidance:
import java.awt.*; public class Circle { public static void main(String[] args) { final double PI = 3.14; int x,y, radius = 4; double area; double perimeter; area = PI * radius * radius; perimeter = 2 * PI * radius; // Output Results System.out.println("The area of the circle is " + area ); System.out.println("The perimeter of the circle is " + perimeter ); } int x, y, radius; public Circle(int x, int y, int radius) { this.x = x; this.y = y; this.radius = radius; } } // For some reason this code has problems. // I tried integrating it into the top code and // That failed, not sure why though. class public Circle(int x, int y, int radius) { this.x = x; this.y = y; this.radius = radius; } public Circle() { this.x = 3; this.y = 3; this.radius = 6; }
I do not know what to do. I have viewed tutorials, but that makes it even more confusing.... I hope you can assist me.
Thank you so much for coping with a noob like me.
Thanks.