-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCoordinate.java
More file actions
112 lines (102 loc) · 2.32 KB
/
Copy pathCoordinate.java
File metadata and controls
112 lines (102 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
* Stores a Coordinate, as well as its relativity
*
* @author Fahim Islam
* Version 1.0.0 (3/25/2022)
* -Created Coordinate.java with 3 constructors, and 3 field variables
* -Included Getters and Setters
*/
public class Coordinate {
// x-coordinate
private int x;
// y-coordinate
private int y;
// whether this is a relative coordinate
private boolean isRelative;
/**
* Default Constructor, sets the field variables to default values
*/
public Coordinate() {
this(0, 0, false);
}
/**
* Constructor, sets the field variables
*
* @param x the x-coordinate
* @param y the y-coordinate
*/
public Coordinate(int x, int y) {
this(x, y, false);
}
/**
* Constructor, sets the field variables
*
* @param x the x-coordinate
* @param y the y-coordinate
* @param isRelative whether this is a relative coordinate, or a regular coordinate
*/
public Coordinate(int x, int y, boolean isRelative) {
this.x = x;
this.y = y;
this.isRelative = isRelative;
}
/**
* setter for the x-coordinate
*
* @param the new x-coordinate
*/
public void setX(int x) {
this.x = x;
}
/**
* setter for the y-coordinate
*
* @param the new y-coordinate
*/
public void setY(int y) {
this.y = y;
}
/**
* getter for the x-coordinate
*
* @return the x-coordinate
*/
public int getX() {
return this.x;
}
/**
* getter for the y-coordinate
*
* @return the y-coordinate
*/
public int getY() {
return this.y;
}
/**
* getter for the isRelative variable
*
* @return the boolean value for the isRelative variable
*/
public boolean getRelativity() {
return this.isRelative;
}
@Override
/**
* Checks whether two objects are equal, by overriding the Coordinate method.
*
* @param the other object
* @return whether the other object equals this object
*/
public boolean equals(Object other) {
if(other instanceof Coordinate && this.x == ((Coordinate)(other)).getX() && this.y == ((Coordinate)(other)).getY()) {
return true;
}
else {
return false;
}
}
public String toString(){
String show = "( "+Integer.toString(Utility.converter_game(x)-4) + ", " +Integer.toString(Utility.converter_game(y)-2)+" )";
return show;
}
}