-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspaces.cpp
More file actions
44 lines (40 loc) · 1 KB
/
spaces.cpp
File metadata and controls
44 lines (40 loc) · 1 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
/**
* @file spaces.cc
* @author Jansen Craft
* @brief Spaces/Cell Class Definition FIle for Othello game
* @date 2022-04-11
*/
#include "spaces.hpp"
#include "colors.hpp"
using namespace std;
//SPACES Mutator
void Spaces::set_state(int userEntry){
if(userEntry >= 0 && userEntry <= 2){
state = userEntry;
} else {
cout << "Error(Spaces): Invalid State" << endl;
}
return;
}
//SPACES flip State
void Spaces::flip(){
if(state == 2){ //blue
state = 1;
} else if (state == 1){ //red
state = 2;
} else if (state == 0){ //Empty
cout << "Error(Spaces): Cannot flip empty Spaces" << endl;
}
return;
}
//SPACES overloaded output operator
ostream& operator <<(ostream& outs, Spaces s){
if(s.get_state() == 2){ //blue Space
cout << BLUE << "\u25CF"<< WHITE;
} else if (s.get_state() == 1){ //red Space
cout << RED << "\u25CF" << WHITE;
} else if (s.get_state() == 0){ //Empty Space
cout << " ";
}
return outs;
}