Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

What is the purpose of the application form?

Answered: 1 week ago