Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 155 lines (112 sloc) 1.825 kB
9fef833 @obradovic afraid of commitment?
authored
1 //
2 // Node Implementation
3 //
4
5 #include "Node.h"
6
7 using namespace std;
8
9
10
11 //
12 // OBJECT ATTRIBUTES
13 //
14
15 bool Node::isTheirs() const
16 {
17 if (myValue == THEIRS) return true;
18 return false;
19 }
20
21
22 bool Node::isOurs() const
23 {
24 if (myValue == OURS) return true;
25 return false;
26 }
27
28 bool Node::isStart() const
29 {
30 if (myValue == START) return true;
31 return false;
32 }
33
34
35 bool Node::isStop() const
36 {
37 if (myValue == STOP) return true;
38 return false;
39 }
40
41
42 bool Node::isVisited() const
43 {
44 return myVisited;
45 }
46
47
48 //
49 // OBJECT MUTATORS
50 //
51 void Node::setId (int x)
52 {
53 myId = x;
54 }
55
56 void Node::setVisited (bool x)
57 {
58 myVisited = x;
59 }
60
61 void Node::x (int x)
62 {
63 myX = x;
64 }
65
66 void Node::y (int x)
67 {
68 myY = x;
69 }
70
71
72
73
74
75 //
76 // OBJECT ACCESSORS
77 //
78 int Node::x () const
79 {
80 return myX;
81 }
82
83
84 int Node::y () const
85 {
86 return myY;
87 }
88
89
90 Node::Value Node::value () const
91 {
92 return myValue;
93 }
94
95 int Node::id () const
96 {
97 return myId;
98 }
99
100
101
102
103 //
104 // BOOKKEEPERS
105 //
106 Node::Node ()
107 {
108 _zero();
109 }
110
111
112 Node::Node (int theX, int theY, int theValue, int theId)
113 {
114 _zero();
115 _initialize (theX, theY, theValue, theId);
116 }
117
118 Node::Node (const Node & theNode)
119 {
120 _initialize (theNode.myX, theNode.myY, theNode.myValue, theNode.myId);
121 }
122
123 void Node::_zero ()
124 {
125 myX = 0;
126 myY = 0;
127 myId = 0;
128 myValue = OURS;
129 myVisited = false;
130 }
131
132 void Node::_initialize (int theX, int theY, int theValue, int theId)
133 {
134 myX = theX;
135 myY = theY;
136 myId = theId;
137 myValue = static_cast <Value> (theValue);
138 }
139
140 Node::~Node ()
141 {
142 }
143
144
145
146
147 //
148 // OUTPUT OPERATOR
149 //
150 ostream & operator << (ostream & theStream, const Node & theNode)
151 {
152 theStream << "(" << theNode.myX << ", " << theNode.myY << ") = " << theNode.myValue << " ";
153 return theStream;
115d615 @obradovic minor cleanup
authored
154 }
Something went wrong with that request. Please try again.