-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSquare.cpp
More file actions
50 lines (43 loc) · 919 Bytes
/
Square.cpp
File metadata and controls
50 lines (43 loc) · 919 Bytes
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
#include "Square.h"
#include <string>
#include <random>
#include <vector>
#include <iostream>
using namespace std;
Square::Square(){
color = "";
number = -1;
};
void Square::flipSquare(){
flipped = true;
};
void Square::generateColor(vector<std::string> colors, vector<int> &numUsed){
bool finished = false;
while(!finished){
int randColor = rand()%colors.size();
if(numUsed[randColor] < 2){
this->color = colors[randColor];
numUsed[randColor]++;
finished = true;
}
}
};
std::string Square::getColor() {
return color;
}
int Square::getNumber(){
return number;
}
void Square::setNumber(int num){
this->number = num;
};
void Square::setColor(string col){
this->color = col;
};
int Square::compareSquares(Square s){
if(this->getColor() == s.getColor()){
return 1;
} else {
return 0;
}
};