-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.cpp
67 lines (53 loc) · 1015 Bytes
/
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
//
// Cell.cpp
// GameOfLife
//
// Jason Hoffman
// 9/25/2015
// Assignment 1, CS162
#include "Cell.h"
// Macro defines height and width for clarity
#define HEIGHT 40
#define WIDTH 60
// Cell initializer sets initial status to false
Cell::Cell() {
for (int i = 0; i < 2; i++) {
status[i] = false;
}
}
void Cell::spawn() {
status[0] = true;
}
void Cell::spawnTemp() {
status[1] = true;
}
void Cell::kill() {
status[0] = false;
}
void Cell::killTemp() {
status[1] = false;
}
bool Cell::isAlive() {
return status[0];
}
void Cell::transfer() {
status[0] = false;
status[0] = status[1];
status[1] = false;
}
void Cell::copy() {
status[1] = status[0];
}
bool Cell::isVisible(int h, int w) {
if ((h > 20 || h < 10) || (w > 50 || w < 10)) {
return false;
} else {
return true;
}
}
bool Cell::isInBounds(int h, int w) {
if ((h >= 0 && w >= 0) && (h < HEIGHT && w < WIDTH)) {
return true;
}
return false;
}