Question: Design a class named Point that meets the following requirements: Two data fields x and y for representing a point with getter methods

Design a class named Point that meets the following requirements:

■ Two data fields x and y for representing a point with getter methods

■ A no-arg constructor that constructs a point for (0, 0)

■ A constructor that constructs a point with the specified x and y values

■ Override the equals method. Point p1 is said to be equal to point p2 if p1.x = = p2.x and p1.y = = p2.y.

■ Override the hashCode method. (For reference, see the implementation of the Point2D class in the Java API.)

Step by Step Solution

3.45 Rating (177 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class Exercise2714 class Point private double x private double ... View full answer

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 Introduction to Java Programming and Data Structure Questions!