Question: Location Envision the world as a grid, where each intersection represents a Location. Each location is marked with a corresponding (x,y) coordinate. Negative x and

Location

Envision the world as a grid, where each intersection represents a Location. Each location is marked with a corresponding (x,y) coordinate. Negative x and y coordinates exist.

Fields and Constructors

A Location should be able to keep track of its own x and y coordinates. By default, a Location is set to (0,0).

Input location that we want to go to and current location this.getX this keyword

Methods

Location should include the following methods:

  • getX() returns its X coordinate

  • getY() returns its Y coordinate

  • setX(int) sets its X coordinate to the new number

  • setY(int) sets its Y coordinate to the new number

  • getDistance(Location) returns the Manhattan distance between itself and the input Location

Please do not include for following as we have not learned it yet: private, math.abs, and args

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!