public class Coordinates
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.Double |
OUT_OF_MAP
Value of a coordinates' value out of map.
|
Constructor and Description |
---|
Coordinates(double x,
double y)
Coordinates base Double constructor.
|
Coordinates(int x,
int y)
Coordinates base Integer constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addX(double adder)
Add value to coordinate X.
|
void |
addY(double adder)
Add value to coordinate Y.
|
static java.lang.Double |
distanceFromTwoPoints(Coordinates p1,
Coordinates p2)
Calculate and return distance from two given points of type Coordinates.
|
static java.lang.Integer |
doubleToInteger(double value)
Round from Double to Integer and return it.
|
static java.lang.Double |
getMaxX()
Return maximum value for coordinate X.
|
static java.lang.Double |
getMaxY()
Return maximum value for coordinate X.
|
int |
getX()
Return value of coordinate X.
|
int |
getY()
Return value of coordinate Y.
|
static boolean |
isLegal(Coordinates point)
Check if a coordinate is legal (inside the map).
|
static void |
setMaxX(double maxX)
Set maximum value for coordinate X.
|
static void |
setMaxY(double maxY)
Set maximum value for coordinate Y.
|
void |
setX(double x)
Set Double value of coordinate X.
|
void |
setX(int x)
Set Integer value of coordinate X.
|
void |
setY(double y)
Set Double value to coordinate Y.
|
void |
setY(int y)
Set Integer value to coordinate Y.
|
java.lang.String |
toString()
Returns a personalized representation of this class.
|
public static final java.lang.Double OUT_OF_MAP
public Coordinates(int x, int y)
x
- coordinate xy
- coordinate ypublic Coordinates(double x, double y)
x
- coordinate xy
- coordinate ypublic int getX() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if value is more than maxX or less than zeropublic void setX(int x)
x
- value to be setpublic void setX(double x)
x
- value to be setpublic void addX(double adder)
adder
- value to be addedpublic int getY() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if value is more than maxY or less than zeropublic void setY(int y)
y
- value to be setpublic void setY(double y)
y
- value to be setpublic void addY(double adder)
adder
- value to be addedpublic static void setMaxX(double maxX)
maxX
- maximum value to be setpublic static java.lang.Double getMaxX()
public static void setMaxY(double maxY)
maxY
- maximum value to be setpublic static java.lang.Double getMaxY()
public static boolean isLegal(Coordinates point)
point
- point to be checkedpublic static java.lang.Integer doubleToInteger(double value)
value
- double to be roundedpublic static java.lang.Double distanceFromTwoPoints(Coordinates p1, Coordinates p2) throws java.lang.NullPointerException
p1
- first pointp2
- second pointjava.lang.NullPointerException
- if p1 or p2 are nullpublic java.lang.String toString()
toString
in class java.lang.Object