-
Notifications
You must be signed in to change notification settings - Fork 1
/
side.cpp
76 lines (68 loc) · 1.56 KB
/
side.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
68
69
70
71
72
73
74
75
76
#include "side.h"
Row* Side::getFront_row() const
{
return front_row;
}
void Side::setFront_row(Row* value)
{
front_row = value;
}
Row* Side::getMid_row() const
{
return mid_row;
}
void Side::setMid_row(Row* value)
{
mid_row = value;
}
Row* Side::getBack_row() const
{
return back_row;
}
void Side::setBack_row(Row* value)
{
back_row = value;
}
Side::Side(QVector<Cube*> cubes)
{
QVector<Cube*> newCubes;
for (int i = 0; i < 9; ++i) {
if (i < 3) {
newCubes.append(cubes.at(i));
if (i == 2) {
front_row = new Row(newCubes);
newCubes.clear();
}
} else if (i < 6) {
newCubes.append(cubes.at(i));
if (i == 5) {
mid_row = new Row(newCubes);
newCubes.clear();
}
} else {
newCubes.append(cubes.at(i));
if (i == 8) {
back_row = new Row(newCubes);
newCubes.clear();
}
}
}
}
QVector<Cube*> Side::getCubes()
{
QVector<Cube*> cubes;
cubes << front_row->getFront_cube() << front_row->getMid_cube() << front_row->getBack_cube()
<< mid_row->getFront_cube() << mid_row->getMid_cube() << mid_row->getBack_cube()
<< back_row->getFront_cube() << back_row->getMid_cube() << back_row->getBack_cube();
return cubes;
}
QVector<int> Side::sideAsIds()
{
QVector<int> ids;
QVector<Cube*> cubes = getCubes();
foreach(Cube * cube, cubes)
{
ids << cube->getId();
}
return ids;
}