Override equals to Compare Two Points
mediumQuestion 518Every class inherits equals(Object other) from Object. The inherited version only returns true when both variables refer to the very same object, so two separate Point objects with the same coordinates are not equal yet. Override it in Point.
Requirements:
1. The header must be public boolean equals(Object other). The parameter type is Object, not Point. With Point you would write a second, overloaded method, and Java's own classes such as ArrayList would keep calling the inherited one.
2. Return false when other is not a Point. This also covers null.
3. Otherwise cast other to Point and return true only when both x values match and both y values match.
The fields, the constructor and the getters are written. Do not change them. In a real project you would override hashCode() together with equals; it is left out here to keep the exercise short.
Do NOT write a main method.
Expected output
true false true false
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...