-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaveGridAction.cpp
More file actions
50 lines (37 loc) · 998 Bytes
/
SaveGridAction.cpp
File metadata and controls
50 lines (37 loc) · 998 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
#include "SaveGridAction.h"
#include"Grid.h"
#include "CardNine.h"
#include "CardEleven.h"
#include "CardTen.h"
SaveGridAction::SaveGridAction(ApplicationManager* pApp) : Action(pApp)
{
}
SaveGridAction:: ~SaveGridAction()
{
}
void SaveGridAction::ReadActionParameters()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("Please enter the name of the file ...");
FileName = pIn->GetSrting(pOut);
FileName = FileName + ".txt";
pOut->ClearStatusBar();
}
void SaveGridAction::Execute()
{
ReadActionParameters();
Grid* pGrid = pManager->GetGrid();
ofstream GridSave(FileName);
CardNine::SetIsSavedF();
CardTen::SetIsSavedF();
CardEleven::SetIsSavedF();
GridSave << pGrid->GetLadderCount() << endl;
pGrid->SaveAll(GridSave, 0);
GridSave << pGrid->GetSnakeCount() << endl;
pGrid->SaveAll(GridSave, 1);
GridSave << pGrid->GetCardCount() << endl;
pGrid->SaveAll(GridSave, 2);
GridSave.close();
}