Question: Add the following accessor method to the Point class: public int manhattanDistance(Point other) Returns the Manhattan distance between the current Point object and the given
Add the following accessor method to the Point class:
public int manhattanDistance(Point other)
Returns the “Manhattan distance” between the current Point object and the given other Point object. The Manhattan distance refers to the distance between two places if one can travel between them only by moving horizontally or vertically, as though driving on the streets of Manhattan. In our case, the Manhattan distance is the sum of the absolute values of the differences in their coordinates; in other words, the difference in x plus the difference in y between the points.
Step by Step Solution
3.39 Rating (161 Votes )
There are 3 Steps involved in it
Returns the Manhattan rectangular distan... View full answer
Get step-by-step solutions from verified subject matter experts
