Based on the following class: public class Circle { // The radius of this circle, and the x & y coordinates of the circle center private double radius, centerX, centerY; //Construct a circle object public Circle(double radius, double centerX, double centerY) { this.radius -radius; this.centerX - centerX; this.centerY - centerY; } //Construct a circle object public Circle() { this (1.0, 1.0, 1.0); } // get and set methods for the private data fields radius, centerX, center Y // an instance distance method } Complete the Circle class by adding three sets of get and set methods for the three private data fields. In the Circle class, add another instance method that is passed a reference variable for a circle object and returns the distance between the circle that is passed to the method and the current circle. Your distance method should have the following signature line: public double distance(Circle c) The distance formula between any two points (x1.y1) and (x2,y2) is given by: d = √(x2-x1)² + (y2 — y1)² Requirements: (1) Draw the UML of the new Circle class; (2) Implement the Circle class; (3) In another program file, implement a test program for a new class named TestCircle with a main method. Save the two program files as Circle.java and TestCircle.java. In the main method of the TestCircle class, use the Circle constructors to create a first circle object with the default radius (use the no-arg constructor for this) and create a second circle object with radius 5.5 and center as (3.5, 4.2). Then test all the get methods, set methods, and the distance method.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Having trouble creating a definition class and test program for it. Need help writing this program in java script on eclipse. Please help. Attatching the assignment instruction and display result in the images.

Circle 1's Radius: 1.0
Circle 1's CenterX: 1.0
Circle 1's CenterY: 1.0
Circle 2's Radius: 5.5
Circle 2's CenterX: 3.5
Circle 2's CenterY: 4.2
Distance from Circlel to Circle2: 4.060788100849391
Transcribed Image Text:Circle 1's Radius: 1.0 Circle 1's CenterX: 1.0 Circle 1's CenterY: 1.0 Circle 2's Radius: 5.5 Circle 2's CenterX: 3.5 Circle 2's CenterY: 4.2 Distance from Circlel to Circle2: 4.060788100849391
Finding the distance between the centers of two circles
Based on the following class:
public class Circle {
// The radius of this circle, and the x & y coordinates of the circle center
private double radius, centerX, center;
//Construct a circle object
public Circle(double radius, double centerX, double centerY) {
this.radius = radius;
this.centerX = centerX;
this.center Y = centerY;
}
//Construct a circle object
public Circle() {
this (1.0, 1.0, 1.0);
}
// get and set methods for the private data fields radius, centerX, centerY
// an instance distance method
}
Complete the Circle class by adding three sets of get and set methods for the three private data
fields. In the Circle class, add another instance method that is passed a reference variable for a
circle object and returns the distance between the circle that is passed to the method and the
current circle. Your distance method should have the following signature line:
public double distance(Circle c)
The distance formula between any two points (x1.y1) and (x2,y2) is given by:
d = √(x2-x1)² + (y2 - y1)²
Requirements: (1) Draw the UML of the new Circle class; (2) Implement the Circle class; (3) In
another program file, implement a test program for a new class named TestCircle with a main
method. Save the two program files as Circle.java and TestCircle.java.
In the main method of the TestCircle class, use the Circle constructors to create a first circle
object with the default radius (use the no-arg constructor for this) and create a second circle
object with radius 5.5 and center as (3.5, 4.2). Then test all the get methods, set methods, and the
distance method.
Transcribed Image Text:Finding the distance between the centers of two circles Based on the following class: public class Circle { // The radius of this circle, and the x & y coordinates of the circle center private double radius, centerX, center; //Construct a circle object public Circle(double radius, double centerX, double centerY) { this.radius = radius; this.centerX = centerX; this.center Y = centerY; } //Construct a circle object public Circle() { this (1.0, 1.0, 1.0); } // get and set methods for the private data fields radius, centerX, centerY // an instance distance method } Complete the Circle class by adding three sets of get and set methods for the three private data fields. In the Circle class, add another instance method that is passed a reference variable for a circle object and returns the distance between the circle that is passed to the method and the current circle. Your distance method should have the following signature line: public double distance(Circle c) The distance formula between any two points (x1.y1) and (x2,y2) is given by: d = √(x2-x1)² + (y2 - y1)² Requirements: (1) Draw the UML of the new Circle class; (2) Implement the Circle class; (3) In another program file, implement a test program for a new class named TestCircle with a main method. Save the two program files as Circle.java and TestCircle.java. In the main method of the TestCircle class, use the Circle constructors to create a first circle object with the default radius (use the no-arg constructor for this) and create a second circle object with radius 5.5 and center as (3.5, 4.2). Then test all the get methods, set methods, and the distance method.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY