Question
You will write two java files for this assignment: MyCircle.java, and MyCircleTester.java. The MyCircle.java file is the primary interest. It will create an actual class,
You will write two java files for this assignment: MyCircle.java, and MyCircleTester.java.
The MyCircle.java file is the primary interest. It will create an actual class, the first one that we have written this semester. The MyCircle class is similar to the Rectangle class from the reading.
The MyCircle class should meet these criteria:
Three member fields
double radius
double x
double y
Eight methods:
Six of the methods are simple: getters and setters for x, y, and radius.
There should also be a getArea method that returns the area (derived from the radius)
A doesOverlap method. This method should accept a MyCircle as an argument, and return true if this circle overlaps the circle that the method was invoked on. [Note: two circles overlap if the sum of their radius' is greater than or equal to the distance between their centers.]
The reading this week discusses one of the UML diagrams. Here is the diagram for the MyCircle class:
MyCircle Class |
double x double y double radius |
void setX(double value) double getX() void setY(double value) double getY() void setRadius(double value) double getRadius() double getArea() boolean doesOverlap(MyCircle otherCircle) |
MyCircleTester
Write a second class named MyCircleTester. It should be in its own file named MyCircleTester.java. It should contain code that tests your MyCircle class. It should have a static main method, and if you want you can put all of the code inside that main method.
I encourage you to spend a significant amount of time testing out the MyCircle class. This is a great way to learn the nuances of java syntax. Feel free to write and erase as much code as you want. (Naturally.)
After you have tested the code to your own satisfaction, submit code that meets these minimum criteria
Allocate and initialize at least three MyCircle objects. Two of them should overlap, and two should not.
Display the areas of the three circles
Invoke doesOverlap on MyCircles to show which circles overlap.
Submit two files, inside a compressed folder. MyCircle.java and MyCircleTester.java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started