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

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

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions