-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpace.cpp
166 lines (137 loc) · 2.07 KB
/
Space.cpp
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/* Program Name: Sword Quest
Author: Centaurus Team 1
Date: October 9, 2018
Description: Base Space class for all 25 spaces in the game
*/
#include "Space.hpp"
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
using namespace std;
// Space Class
Space::Space()
{
name = "No name";
shortForm = "";
longForm = "";
id = 0;
obj = NULL;
combatEncounter = false;
visited = false;
}
Space::~Space()
{}
string Space::getName()
{
return name;
}
string Space::getShortForm()
{
return shortForm;
}
string Space::getLongForm()
{
return longForm;
}
void Space::printSpace()
{
if (visited == false)
{
cout << "Current Location: " << getName() << endl;
cout << getLongForm() << endl;
}
else
{
cout << "Current Location: " << getName() << endl;
cout << getShortForm() << endl;
}
}
int Space::getId()
{
return id;
}
Space* Space::getNorth()
{
return north;
}
Space* Space::getEast()
{
return east;
}
Space* Space::getSouth()
{
return south;
}
Space* Space::getWest()
{
return west;
}
Objects Space::getObject()
{
return *obj;
}
// TEST****************************************8
void Space::addToContainer(Objects obj)
{
cout << "You drop the " << obj.getName() << endl;
space.push_back(obj);
}
void Space::deleteFromContainer(Objects obj)
{
cout << "You pick up the " << obj.getName() << endl;
for(int i = 0; i < space.size(); i++)
{
if(space[i].getName() == obj.getName())
{
space.erase(space.begin() + i);
return;
}
}
}
void Space::printContainer()
{
for(int i = 0; i < space.size(); i++)
{
cout << space[i].getName() << endl;
}
}
void Space::setDirections(Space* N, Space* E, Space* S, Space* W)
{
north = N;
east = E;
south = S;
west = W;
}
bool Space::getEncounter()
{
return combatEncounter;
}
void Space::setVisited()
{
visited = false;
}
bool Space::getVisited()
{
if (visited == false)
{
visited = true;
return false;
}
else
{
return true;
}
}
bool Space::checkVisited()
{
return visited;
}
Objects Space::printItem(int i)
{
return space[i];
}
int Space::getSize()
{
return space.size();
}