/
puzzlewindow.cpp
67 lines (57 loc) · 1.42 KB
/
puzzlewindow.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
#include "puzzlewindow.h"
#include "ui_mainwindow.h"
#include <QtDebug>
PuzzleWindow::PuzzleWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::PuzzleWindow)
{
ui->setupUi(this);
QBrush red(Qt::red);
QPen black(Qt::black);
black.setWidth(10);
scene = new QGraphicsScene(this);
scene->setSceneRect(0,0,100,100);
ui->graphicsView->setScene(scene);
/*timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),scene,SLOT(advance()));
timer->start(100);
*/
rec = scene->addRect(0,0,100,100,black,red);
Board *aBoard = new Board();
aBoard->setInitState();
delete aBoard;
}
PuzzleWindow::~PuzzleWindow()
{
delete ui;
}
unsigned PuzzleWindow::getNumberofMisplacedTile(Board testBoard, Board goalBoard)
{
Dimension theDimension;
theDimension = testBoard.getDimension();
unsigned ROWS = theDimension.getRow();
unsigned COLS = theDimension.getCol();
unsigned start = 1;
unsigned counter =0;
for(unsigned i = 0;i < ROWS;++i)
{
for(unsigned j = 0;j < COLS;++j)
{
//if(start != testBoard[i][j].getNumber())
{
counter++;
}
start++;
}
}
return counter;
}
void PuzzleWindow::on_pushButton_clicked()
{
rec->setPos(50,50);
}
void PuzzleWindow::on_pushButton_2_clicked()
{
rec->setPos(30,30);
}
void PuzzleWindow::on_pushButton_3_clicked()
{
}