-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGraphNode.java
81 lines (67 loc) · 1.54 KB
/
GraphNode.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
/**
* GraphNode.java, an object that stores information about a graph node for
* Tree Applicatons.<br>
* Extends: KeyedItem.<br>
* Author: Matt Markham
*/
public class GraphNode extends KeyedItem
{
private int xCoord, yCoord;
boolean mark;
GraphNode (Comparable item)
{
super(item);
mark=false;
}
GraphNode (Comparable item, int x, int y)
{
super(item);
xCoord=x;
yCoord=y;
mark=false;
}
/**
* Returns the x-coordinate of the current Graph Node.<br>
* Preconditions: None.<br>
* Postconditions: Returns int value of this nodes x position.<br>
* Throws: None
*/
public int getX()
{
return xCoord;
}
/**
* Returns the y-coordiante of the current Graph Node.<br>
* Preconditions: None.<br>
* Postconditions: Returns int value of this nodes y position.<br>
* Throws: None
*/
public int getY()
{
return yCoord;
}
/**
* Returns true if node is marked, false if it is not.<br>
* Preconditions: None.<br>
* Postconditions: returns true if node is marked, false if it is not.
* Throws: None.
*/
public boolean isMarked()
{
return mark;
}
/**
* Sets value of mark to true or false.<br>
* Preconditions: Must be passed in a boolean.<br>
* Postconditions: Sets mark to passed-in boolean.<br>
* Throws: None.
*/
public void setMarked(boolean setbool)
{
mark=setbool;
}
public boolean equals (GraphNode node)
{
return ((node.getX() == xCoord)&&(node.getY()==yCoord) && (node.getKey().compareTo(this.getKey())==0));
}
}