-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTile.cpp
More file actions
54 lines (45 loc) · 920 Bytes
/
Tile.cpp
File metadata and controls
54 lines (45 loc) · 920 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
51
52
53
54
#include <iostream>
#include "Tile.h"
Tile::Tile(){
this->setValue( 0 );
}
Tile::Tile( int value ){
this->setValue( value );
}
int Tile::getValue() {
return this->value;
}
Tile Tile::copy() {
Tile t;
t.setValue( this->getValue() );
t.x = this->x;
t.y = this->y;
return t;
}
void Tile::setValue( int value ) {
this->value = value;
}
std::string Tile::toString() {
std::string returnString = " ";
if (this->value != 0) {
std::string str = std::to_string(this->value);
switch (str.length()) {
case 4:
returnString[0] = str[0];
returnString[1] = str[1];
returnString[2] = str[2];
returnString[3] = str[3];
break;
case 3:
returnString[3] = str[2];
case 2:
returnString[2] = str[1];
case 1:
returnString[1] = str[0];
break;
default:
break;
}
}
return returnString;
}