-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint_2D.java
More file actions
74 lines (63 loc) · 1.34 KB
/
Copy pathPoint_2D.java
File metadata and controls
74 lines (63 loc) · 1.34 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
package primitives;
public class Point_2D {
protected Coordinate _x;
protected Coordinate _y;
// ***************** Constructors ********************** //
/**
* construct 2D point with two coordinates
*
* @param x
* - coordinate
* @param y
* - coordinate
*/
public Point_2D(Coordinate x, Coordinate y) {
_x = x;
_y = y;
}
/**
* construct 2D point with 2 numbers
*
* @param x
* - double
* @param y
* - double
*/
public Point_2D(double x, double y) {
_x = new Coordinate(x);
_y = new Coordinate(y);
}
/**
* copy constructor
*
* @param other
* - Poimt_2D
*/
public Point_2D(Point_2D other) {
_x = other._x;
_y = other._y;
}
// ***************** Getters/Setters ********************** //
public Coordinate x() {
return _x;
}
public Coordinate y() {
return _y;
}
// ***************** Operations ******************** //
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Point_2D))
return false;
Point_2D other = (Point_2D) obj;
return _x.equals(other._x) && _y.equals(other._y);
}
@Override
public String toString() {
return "[x=" + _x + ", y=" + _y + "]";
}
}