-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaveGridAction.cpp
More file actions
49 lines (41 loc) · 1.09 KB
/
SaveGridAction.cpp
File metadata and controls
49 lines (41 loc) · 1.09 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
#include "SaveGridAction.h"
#include "Input.h"
#include "Output.h"
#include "Grid.h"
#include <string>
#include <fstream>
#include<iostream>
using namespace std;
SaveGridAction::SaveGridAction(ApplicationManager* pApp) : Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
void SaveGridAction:: ReadActionParameters()
{
//Get pointer to the input class
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
//Get The FileName and its validation
pOut->PrintMessage("Enter the name of the file.......");
filename = pIn->GetSrting(pOut);
//ClearStatusBar
pOut->ClearStatusBar();
}
void SaveGridAction::Execute()
{
Grid* pGrid = pManager->GetGrid();
ReadActionParameters();
//open file_
ofstream file(filename+".txt");
//A- We get a pointer to the Grid from the ApplicationManager
//saving data
pGrid->SaveAll(file, ladder);
pGrid->SaveAll(file, snake);
pGrid->SaveAll(file, card);
//close file_
file.close();
}
SaveGridAction::~SaveGridAction()
{
}