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

Program 4: Circle.java You will create another basic class called Circle. java f

ID: 646957 • Letter: P

Question

Program 4: Circle.java You will create another basic class called Circle. java for representing circles. You should provide: Constructors: Your circles must be immutable, that is. once a Circle object is created, there must be no way to change its radius and center. You may reuse the distance() functions from Point2D. Make sure both classes are in the same project so you can the Point2D class and its methods in Circle. java. Both should be in default package. In your main method, write a program that tests your Circle class by instantiating circles, calling static methods versus instance methods and printing their results to the console. You do not need to get input from the user but come np with good test cases.

Explanation / Answer

import java.awt.*; public class Circle { private int radius; public Circle() { radius = 1; } public Circle(int x, int y, int r) { super(x, y, c); radius = r; } public int getRadius() { return radius; } public double getArea() { return Math.PI * radius * radius; } public double getPerimeter() { return 2 * Math.PI * radius; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote