-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPosition.java
82 lines (68 loc) · 1.65 KB
/
Position.java
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
/**
* Course: 5DV133
* Written by: Erik Dahlberg c15edg
* @Author Group 15 - 5DV133 vt2016
* @Version 1.0
*/
/**
* Represents x and y axis to navigate by position in Network
*/
public class Position {
private int x;
private int y;
/**
* will take to x and y param and update positions x and y values.
* @param x - represents x-axis
* @param y - represent y-axis
*/
public Position (int x, int y){
this.x = x;
this.y = y;
}
/**
* Will return the value representing x-axis
* @return value that represents x-axis
*/
public int getX(){
return x;
}
/**
* Will return the value representing y-axis
* @return value that represents y-axis
*/
public int getY(){
return y;
}
/**
* Convert x and y to String, example string (3,3)
* @return string with x and y value
*/
public String toString(){
return "(" + x + "," + y + ")";
}
/**
* Compare method
* Auto intellij generated equals method
* @param o is object to compare with
* @return boolean true or false
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Position position = (Position) o;
if (x != position.x) return false;
return y == position.y;
}
/**
* Will return hashcode
* Auto intellij generated hashcode method
* @return int of hashcode
*/
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
return result;
}
}