-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
77 lines (64 loc) · 1.87 KB
/
Node.java
File metadata and controls
77 lines (64 loc) · 1.87 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
import java.util.ArrayList;
public class Node {
private CoordPair pos;
private ArrayList<Node> connected = new ArrayList<Node>();
/**
* Constructor for making node at given position
* will make a new CoordPair object
* @param x the x position
* @param y the y position
* @param z the z position
*/
public Node(double x, double y, double z) {
this.pos = new CoordPair(x, y, z);
}
public Node(int x, int y, int z) {
this((double)x, (double)y, (double)z);
}
public Node(double x, double y) {
this(x, y, 0);
}
public Node(int x, int y) {
this(x, y, 0);
}
/**
* Constructor for making node with position of given coordinate pair
* will use the given CoordPair object
* @param pos the CoordPair object to use for the position of the new node
*/
public Node(CoordPair pos) {
this.pos = pos;
}
public Node() {
this(0, 0, 0);
}
/**
* Adds another node to the arraylist of connected nodes
* @param n the node to add to the connected list
* @param fill true: add this node to n's connected list; false: no change to n's list
*/
public void add_connection(Node n, boolean fill) {
connected.add(n);
if (fill) {
n.add_connection(this, false);
}
}
public void add_connection(Node n) {
add_connection(n, true);
}
public CoordPair get_pos() {
return this.pos;
}
public double get_angle() {
return this.directionAngle;
}
public void set_pos(CoordPair newPos) {
if (newPos == null) {
throw new IllegalArgumentException("###ERROR: Null position passed to the Node's set_pos() function");
}
this.pos = newPos;
}
public ArrayList<Node> get_connected() {
return this.connected;
}
}