-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.cpp
More file actions
137 lines (112 loc) · 2.15 KB
/
Node.cpp
File metadata and controls
137 lines (112 loc) · 2.15 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "Node.h"
Node::Node()
{
description = 0;
north = 0;
south = 0;
east = 0;
west = 0;
is_death = false;
}
Node::Node(const Node& to_copy)
:description(to_copy.description),
north(to_copy.north),
south(to_copy.south),
east(to_copy.east),
west(to_copy.west),
is_death(to_copy.is_death)
{
}
Node::~Node ()
{
}
Node& Node::operator= (const Node& to_copy)
{
if (&to_copy != this)
{
// nothing from destructor
// no base class from which to call operator
// from copy constructor
description = to_copy.description;
north = to_copy.north;
south = to_copy.south;
east = to_copy.east;
west = to_copy.west;
is_death = to_copy.is_death;
}
return *this;
}
Node::Node(unsigned int description1,
unsigned int north1,
unsigned int south1,
unsigned int east1,
unsigned int west1,
bool is_death1)
{
description = description1;
north = north1;
south = south1;
east = east1;
west = west1;
is_death = is_death1;
}
void Node::debugPrint () const
{
if(is_death)
cout << 'D' << endl;
else
cout << 'N' << endl;
cout << "Description number is: " << description << endl;
cout << "North is: " << north << endl;
cout << "South is: " << south << endl;
cout << "East is: " << east << endl;
cout << "West is: " << west << endl;
}
Node* Node::getClone () const
{
Node* pNode = new Node(*this);
return pNode;
}
bool Node::isObstructed () const
{
return false;
}
char Node::getRequiredItem () const
{
assert(isObstructed () == true);
return REQUIRED_ITEM_NOT_SET;
}
unsigned int Node::getDescriptionFailure () const
{
assert(isObstructed());
return 0;
}
unsigned int Node::getDescriptionSuccess () const
{
assert(isObstructed());
return 0;
}
unsigned int Node::getDescription () const
{
return description;
}
bool Node::isDeath () const
{
return is_death;
}
Location Node::getNorth () const
{
return north;
}
Location Node::getSouth () const
{
return south;
}
Location Node::getEast() const
{
return east;
}
Location Node::getWest() const
{
return west;
}