Class Coordinate

java.lang.Object
com.deco2800.game.areas.MapGenerator.Coordinate

public class Coordinate extends Object
Coordinates represent a cartesian point on the map and are used to assist in processing data in the dynamic generation of the map
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for an empty coordinate, assumes (0,0) starting location
    Coordinate(int x, int y)
    Constructs a new coordinate at the given (x,y) position
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object other)
    Coordinates are equal if their x and y values coincide.
    int
    Getter function to return the x value of this coordinate
    int
    Getter function to return the y value of this coordinate
    int
     
    boolean
    inBounds(int mapWidth, int mapHeight)
    Returns whether a coord is in map bounds
    boolean
    Returns whether a coord is in map bounds of the specified MapGenerator
    Coordinates can be more easily visualised in typical cartesian form of "(x, y)" The toString() function is overridden to allow debugging of errors

    Methods inherited from class java.lang.Object

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

    • Coordinate

      public Coordinate(int x, int y)
      Constructs a new coordinate at the given (x,y) position
      Parameters:
      x - x position to initiate coordinate at
      y - y position to initiate coordinate at
    • Coordinate

      public Coordinate()
      Default constructor for an empty coordinate, assumes (0,0) starting location
  • Method Details

    • getX

      public int getX()
      Getter function to return the x value of this coordinate
      Returns:
      associated x value
    • getY

      public int getY()
      Getter function to return the y value of this coordinate
      Returns:
      associated y value
    • inBounds

      public boolean inBounds(MapGenerator mg)
      Returns whether a coord is in map bounds of the specified MapGenerator
      Parameters:
      mg - MapGenerator with which this coordinate is referencing
      Returns:
      true if in bounds, false otherwise
    • inBounds

      public boolean inBounds(int mapWidth, int mapHeight)
      Returns whether a coord is in map bounds
      Parameters:
      mapWidth - width of the map
      mapHeight - height of the map
      Returns:
      true if in bounds, false otherwise
    • equals

      public boolean equals(Object other)
      Coordinates are equal if their x and y values coincide. The equals function is overriden to reflect this
      Overrides:
      equals in class Object
      Parameters:
      other - other object being compared to this coordinate
      Returns:
      true if they are equal by the above definition, false otherwise
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Coordinates can be more easily visualised in typical cartesian form of "(x, y)" The toString() function is overridden to allow debugging of errors
      Overrides:
      toString in class Object
      Returns:
      human-readable representation of a coordinate