-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.cpp
43 lines (38 loc) · 933 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
/**
*cpp file of class Cell
*Authors Alexey Titov and Shir Bentabou
*Version 1.0
**/
//library
#include "Board.h"
//Empty constructor.
Cell::Cell(){}
//Function that sets value in Cell object.
void Cell::setValue(const char& c){
this->value=c;
}
//Function that gets value from Cell object.
const char Cell::getValue(){
return this->value;
}
//Operator '=' overloading for Cell class. If the char given is not 'X' or 'O' - an exception is thrown.
Cell& Cell::operator=(char c){
if (c=='X' || c=='O' || c=='.'){
this->value=c;
return *this;
}
else{
IllegalCharException ce;
ce.setCh(c);
throw ce;
}
}
//Operator casting from Cell to char
Cell::operator char() const{
return this->value;
}
//Operator '<<' overloading for Cell class.
ostream& operator<< (ostream& os, Cell& c){
os << c.getValue();
return os;
}