Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

e1 Implement the Point class (basic Point class was discussed in the lecture). The class has the following instance variables: 1. x coordinate 2. y

e1 image text in transcribed
Implement the Point class (basic Point class was discussed in the lecture). The class has the following instance variables: 1. x coordinate 2. y coordinate and the following methods: 3. Constructor that sets the x and y coordinates 4. Appropriate get and set methods 5. Method equals that returns true only if this Point is equal to another Point object (if the x and y coordinates are the same). 6. Method is Farther Left if this point is farther to the left than another Point object (if the x coordinate of this Point is less than the x coordinate of the other Point) 7. Method find Distance that calculates the length of the line connecting this Point to another Point object (Use the Euclidean distance formula for the length between two points (x1, y1) and (x2, y2), which is the square root of ((x2 - x1) + (y2 - y1)^2) Test the class. In the demo program, construct four points p1, p2, p3 and p4 using user-defined values. Determine Which point is farthest to the left. (If two points are equivalently far, you may report either point). whether the line p1 rightarrow p2 is longer than line p3 rightarrow p4. A sample screen dialog is given below: Enter the x and y coordinates for point1: -9 7 Enter the x and y coordinates for point2: 5 -7 Enter the x and y coordinates for point3: 4 -3 Enter the x and y coordinates for point4: 0 -2 [-9, 7] is the farthest point to the left The length between [-9, 7] and [5, -7) is 19.79898987322333 The length between [4, -3] and [0, -2) is 4.123105625617661 Line from [-9, 7] to [5, -7] is 4.123105625617661 Line from [-9, 7] to [5, -7] is longer

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

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

=+ What are the information and consultation requirements?

Answered: 1 week ago

Question

=+ Should the MNE belong (why, why not)?

Answered: 1 week ago