Class Coordinate
java.lang.Object
com.deco2800.game.areas.MapGenerator.Coordinate
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
ConstructorsConstructorDescriptionDefault constructor for an empty coordinate, assumes (0,0) starting locationCoordinate
(int x, int y) Constructs a new coordinate at the given (x,y) position -
Method Summary
Modifier and TypeMethodDescriptionboolean
Coordinates are equal if their x and y values coincide.int
getX()
Getter function to return the x value of this coordinateint
getY()
Getter function to return the y value of this coordinateint
hashCode()
boolean
inBounds
(int mapWidth, int mapHeight) Returns whether a coord is in map boundsboolean
inBounds
(MapGenerator mg) Returns whether a coord is in map bounds of the specified MapGeneratortoString()
Coordinates can be more easily visualised in typical cartesian form of "(x, y)" The toString() function is overridden to allow debugging of errors
-
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 aty
- 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
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 mapmapHeight
- height of the map- Returns:
- true if in bounds, false otherwise
-
equals
Coordinates are equal if their x and y values coincide. The equals function is overriden to reflect this -
hashCode
public int hashCode() -
toString
Coordinates can be more easily visualised in typical cartesian form of "(x, y)" The toString() function is overridden to allow debugging of errors
-