Question: Write a class Point that represents a two-dimensional point (x,y) in the Java programming language. Two-Argument Constructor to set the Point object to a

Write a class Point that represents a two-dimensional point (x,y) in the Java programming language.

 
  • Two-Argument Constructor to set the Point object to a particular point
  • Zero-Argument Constructor to set the Point object to (0,0)
  • Two Accessor Methods --> double getX() | double getY()

This class should be immutable (if possible) but include a method Point translation(double dx, double dy), which returns a new point after moving this point dx in the x direction and dy in the y direction. This method should NOT mutate the object executing the method.

  • toString() Method --> Returns Standard (x,y) Representation of Point
  • equals() Method

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 Programming Questions!