-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cell.cpp
219 lines (194 loc) · 2.81 KB
/
Cell.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/*
Arsh Chauhan and Tristan Craddick
2/24/2016
Last Edited: 03/10/2016
Source files for header Cell
*/
#include "Cell.h"
#include <tuple>
using std::tuple;
using std::make_tuple;
/*
isOccupied
Pre: None
Post: Returns true if cell is occupied
*/
bool Cell::isOccupied()
{
return isOccupied_;
}
/*
isHead
Pre: None
Post: Returns true if cell is the head of ship
*/
bool Cell::isHead()
{
return isHead_;
}
/*
isHit
Pre: None
Post: Returns true if cell is a 'hit'
*/
bool Cell::isHit()
{
return isHit_;
}
/*
isMiss
Pre: None
Post: Returns true if cell is a 'miss'
*/
bool Cell::isMiss()
{
return isMiss_;
}
/*
isSunk
Pre: None
Post: Returns true if cell is part of a sunken ship
*/
bool Cell::isSunk()
{
return isSunk_;
}
/*
isTarSunk
Pre: None
Post: Returns true if target cell is of a sunken ship.
*/
bool Cell::isTarSunk()
{
return isTarSunk_;
}
/*
setOccupied
Pre: None
Post: Sets cell to occupied state
*/
void Cell::setOccupied()
{
isOccupied_ = true;
}
/*
setHead
Pre: None
Post: Cell is now a head of some ship
*/
void Cell::setHead()
{
isHead_ = true;
}
/*
setHit
Pre: None
Post: Cell is now a 'hit'
*/
void Cell::setHit()
{
isHit_ = true;
}
/*
setMiss
Pre: None
Post: Cell is now a 'miss'
*/
void Cell::setMiss()
{
isMiss_ = true;
}
/*
setSunk
Pre: None
Post: Cell is now a part of a sunken ship
*/
void Cell::setSunk()
{
isSunk_ = true;
}
/*
setSunk
Pre: None
Post: Cell is now a part of a sunken ship.
*/
void Cell::setTarSunk()
{
isTarSunk_ = true;
}
/*
removeHead
Pre: None
Post: The cell is now longer the head, or occupied
*/
void Cell::removeHead()
{
isHead_ = false;
isOccupied_ = false;
}
/*
removeOccupied
Pre: None
Post: Cell is no longer occupied
*/
void Cell::removeOccupied()
{
isOccupied_ = false;
}
/*
getBounds
Pre: None
Post: returns a tuple containing the 4 bounds of a cell.
*/
tuple<float,float,float,float> Cell::getBounds()
{
return make_tuple <float&,float&,float&,float&> (bottomBound_,topBound_,leftBound_,rightBound_);
}
/*
setBounds
Pre: None
Post: sets the 4 bound-variables of a cell to the passed in bounds.
*/
void Cell::setBounds(float topBound, float bottomBound, float leftBound, float rightBound)
{
topBound_ = topBound;
bottomBound_ = bottomBound;
leftBound_ = leftBound;
rightBound_ = rightBound;
}
/*
setSquareHover
Pre: None
Post: sets the variable for the mouse hovering over the square to true
*/
void Cell::setSquareHover(bool mouseOver)
{
squareHover_ = mouseOver;
}
/*
getSquareHover
Pre: None
Post: returns whether or not the square is currently being hovered over
*/
bool Cell::getSquareHover()
{
return squareHover_;
}
/*
getID
Pre: None
Post: returns the ship ID associated with the cell
*/
int Cell::getID()
{
return ship_ID;
}
/*
setMiss
Pre: None
Post: sets the ship ID associated with the cell.
*/
void Cell::setID(int num)
{
ship_ID = num;
}