-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExec.cpp
67 lines (58 loc) · 1.43 KB
/
Exec.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
/* @Author: Anna Fritz
* @File: main.cpp
* @Date: March 27, 2019
* @Brief: Main, interacts with command line
*/
#include "Exec.h"
Exec::Exec(string filename)
{
m_filename = filename;
m_mazeRead = new MazeReader(m_filename);
}
void Exec::run()
{
readingMaze();
goingThroughMaze();
}
void Exec::readingMaze()
{
m_maze = m_mazeRead->getMaze();
m_numCol = m_mazeRead->getCols();
m_numRow = m_mazeRead->getRows();
m_startCol = m_mazeRead->getStartCol();
m_startRow = m_mazeRead->getStartRow();
m_mazeWalk = new MazeWalker (m_maze, m_startRow, m_startCol, m_numRow, m_numCol);
}
void Exec::goingThroughMaze()
{
bool success = false;
// creating visited array
const int* const* visitedmaze = m_mazeWalk->getVisited();
// seeing if array was filled
success = m_mazeWalk -> walkMaze();
if (success == true)
{
cout << "Here is the the way out: " << endl;
visitedmaze = m_mazeWalk -> getVisited();
for (int i = 0; i < m_mazeWalk->getVisitedRows(); i++)
{
for (int j = 0; j < m_mazeWalk->getVisitedCols(); j++)
{
if (visitedmaze[i][j] >= 10)
{
cout << visitedmaze[i][j] << " ";
}
else
{
cout << visitedmaze[i][j] << " ";
}
}
cout << endl;
}
cout << "We escaped!" << endl;
}
if (success == false)
{
cout << "There is no way out!" << endl;
}
}