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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started