-
Notifications
You must be signed in to change notification settings - Fork 0
/
Space.cpp
101 lines (85 loc) · 2.41 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
/***************************************************************************************************
* Name: Jessica Albert
* Project: Final Project - Space.hpp
* Date: 3/8/19
* Description: The Space class is an abstract class that represents a space on a game board. It
* has 4 Space pointers that are used to link together a board of Spaces. It has 3 other data
* members, a bool to track whether a player occupies this space, a character that indicates what
* type of space the space is when the board is printed, and string that holds the type of space.
* All functions are pure virtual, however the setter and getter functions for the data members
* are defined to avoid re-writing the code in each inherited class. The other pure virtual functions
* include one to get a random number, one to display a menu with the user's movement options, a
* setback and positive outcome function, and a function to get a random event.
* ************************************************************************************************/
#include "Space.hpp"
#include <iostream>
Space::Space()
{
this->up = NULL;
this->down = NULL;
this->next = NULL;
this->prev = NULL;
this->playerOccupies = false;
}
/***************************************************************************************************
* The following are setter and getter functions for each protected data member. *
* ************************************************************************************************/
bool Space::getPlayerOccupies()
{
return this->playerOccupies;
}
void Space::setPlayerOccupies(std::string set)
{
if(set == "true")
this->playerOccupies = true;
else if(set == "false")
this->playerOccupies = false;
}
char Space::getSymbol()
{
return this->symbol;
}
void Space::setSymbol(char newSymbol)
{
this->symbol = newSymbol;
}
std::string Space::getType()
{
return this->type;
}
void Space::setType(std::string newType)
{
this->type = newType;
}
void Space::setUp(Space * newUp)
{
this->up = newUp;
}
void Space::setDown(Space * newDown)
{
this->down = newDown;
}
void Space::setNext(Space * newNext)
{
this->next = newNext;
}
void Space::setPrev(Space * newPrev)
{
this->prev = newPrev;
}
Space* Space::getUp()
{
return this->up;
}
Space* Space::getDown()
{
return this->down;
}
Space* Space::getNext()
{
return this->next;
}
Space* Space::getPrev()
{
return this->prev;
}