-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaveAction.cpp
More file actions
68 lines (57 loc) · 1.35 KB
/
Copy pathSaveAction.cpp
File metadata and controls
68 lines (57 loc) · 1.35 KB
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
#include "SaveAction.h"
SaveAction::SaveAction(ApplicationManager* pApp) : Action(pApp)
{
F = "";
}
void SaveAction::ReadActionParameters()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("Enter the file name");
F = pIn->GetSrting(pOut);
pOut->ClearStatusBar();
F = "saves/" + F + ".txt";
}
void SaveAction::Execute()
{
ReadActionParameters();
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
ofstream inF(F, ios::out);
pGrid->SaveAll(inF);
inF.close();
//inF << Ladder::GetNumberOfLadders() << endl;
//inF << Snake::GetNumberOfSnakes() << endl;
//inF << Card::GetNumberOfCards() << endl;
//int num = pGrid->GetLaddersNum();
//inF << num << "\n";
//int** Ladders = pGrid->GetLadders(num);
//for (int i = 0; i < num; ++i)
//{
// inF << Ladders[i][0] << " " << Ladders[i][1] << "\n";
//}
//for (int i = 0; i < num; ++i)
//{
// delete[] Ladders[i];
//}
//if (num != 0)
//delete[] Ladders;
//num = pGrid->GetSnakesNum();
//inF << num << "\n";
//int** Snakes = pGrid->GetSnakes(num);
//for (int i = 0; i < num; ++i)
//{
// inF << Snakes[i][0] << " " << Snakes[i][1] << "\n";
//}
//for (int i = 0; i < num; ++i)
//{
// delete[] Snakes[i];
//}
//if(num !=0)
//delete[] Snakes;
}
SaveAction::~SaveAction()
{
}