Question: write a class that represents a point on the two-dimensional plane. Each point object is represented by x and y coordinates, both double-precision floating point

write a class that represents a point on the two-dimensional plane.

Each point object is represented by x and y coordinates, both double-precision floating point numbers.

The Point class should have public methods for the following:

Set the X coordinate.

Set the Y coordinate.

Get the X coordinate.

Get the Y coordinate.

Add two points (the result is a point).

Subtract two points (the result is a point).

Get the angle (phi) of the point in polar coordinates.

Get the distance (r) of the point in polar coordinates.

Set the X and Y coordinates given polar coordinates (angle and distance).

Write a program that tests your new Point class. Your test code should test each public method in the Point class.

the method that adds two points could be implemented as a static method that takes two points as parameters, or as an instance method that takes a second point to add to the current instance.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!