Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 2 in JAVA: Create a class called Point that has the following: Integers x and y that represent the x and y coordinates of

image text in transcribed

Exercise 2 in JAVA: Create a class called Point that has the following: Integers x and y that represent the x and y coordinates of the point. Constructors and other basic methods Method Point another) that returns the distance of this point from another point (Note: Given the two points (ri, y) and (r2, y2), the distance between these points is given by the formula: Test your methods using a client program with a main method. Next create a class called Circle that has the following: Attributes: Center of the circle (a Point) and radius (double) A no-arg constructor that creates a default circle with (0,0) as center and 1.0 as radius A constructor that creates a circle with the specified center and radius A method getArea() that returns the area of the circle. A method getPerimeter) that returns the perimeter of the circle A method contains(Point p) that returns true if this circle contains a point p (see Figure 1) A method touches(Point p) that returns true if this circle touches a point p (see Figure 2) A method contains(Circle c) that returns true if the specified circle is inside this circle (See Figure 3) Test all methods using a client program with a main method (you should have at least 3 tests and make sure that you include all the three cases as shown in the figures below) Figure 1 Figure 2 Figure 3 Hint: You can determine if a point is inside a circle by the following procedure: Measure the distance of that point from the center. If it is more than the radius, then the point is outside; if it is less than the radius, then it is inside; if it is equal to the radius, then it touches the circle Files for submission: Point.java, Circle.java and CircleDemo.java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions