A class called MyCircle, which models a circle with a center (x,y) and a radius, is designed as shown in the class diagram. The MyCircle class uses an instance of MyPoint class (created in the previous exercise) as its center. The class contains: Two private instance variables: center (an instance of MyPoint) and radius (int). A constructor that constructs a circle with the given center's (x, y) and radius. An overloaded constructor that constructs a MyCircle given a MyPoint instance as center, and radius. A default constructor that construct a circle with center at (0,0) and radius of 1. Various getters and setters. A toString() method that returns a string description of this instance in the format "MyCircle[radius=r,center=(x,y)]". You shall reuse the toString() of MyPoint. getArea() and getCircumference() methods that return the area and circumference of this circle in double. A distance(MyCircle another) method that returns the distance of the centers from this instance and the given MyCircle instance. You should use MyPoint’s distance() method to compute this distance. Write the MyCircle class. Also write a test driver (called TestMyCircle) to test all the public methods defined in the class

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question
100%

A class called MyCircle, which models a circle with a center (x,y) and a radius, is designed as shown in the class diagram. The MyCircle class uses an instance of MyPoint class (created in the previous exercise) as its center.

The class contains:

Two private instance variables: center (an instance of MyPoint) and radius (int).
A constructor that constructs a circle with the given center's (x, y) and radius.
An overloaded constructor that constructs a MyCircle given a MyPoint instance as center, and radius.
A default constructor that construct a circle with center at (0,0) and radius of 1.
Various getters and setters.
A toString() method that returns a string description of this instance in the format "MyCircle[radius=r,center=(x,y)]". You shall reuse the toString() of MyPoint.
getArea() and getCircumference() methods that return the area and circumference of this circle in double.
A distance(MyCircle another) method that returns the distance of the centers from this instance and the given MyCircle instance. You should use MyPoint’s distance() method to compute this distance.
Write the MyCircle class. Also write a test driver (called TestMyCircle) to test all the public methods defined in the class

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning