Class Location

java.lang.Object
itumulator.world.Location

public class Location extends Object
Provides an abstraction to deal with coordinates (x,y) and compare them.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Location(int x, int y)
    Creates a new location
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Allows comparison of two locations according to their x,y coordinates
    int
    Gets the x coordinate of the location
    int
    Gets the y coordinate of the location
    int
    Provides a hash value of the location based on their x,y coordinates (assuming no larger coordinates than 1000).
    Provides the location in a string format of (x, y).

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Location

      public Location(int x, int y)
      Creates a new location
      Parameters:
      x - coordinate
      y - coordinate
  • Method Details

    • getX

      public int getX()
      Gets the x coordinate of the location
      Returns:
      the x coordinate (int)
    • getY

      public int getY()
      Gets the y coordinate of the location
      Returns:
      the y coordinate (int)
    • toString

      public String toString()
      Provides the location in a string format of (x, y).
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Allows comparison of two locations according to their x,y coordinates
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Provides a hash value of the location based on their x,y coordinates (assuming no larger coordinates than 1000).
      Overrides:
      hashCode in class Object