-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSave.cpp
More file actions
36 lines (36 loc) · 1.14 KB
/
Copy pathSave.cpp
File metadata and controls
36 lines (36 loc) · 1.14 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
#include "Save.h"
#include "Grid.h"
#include"fstream"
#include "DEFS.h"
void Save::ReadActionParameters()
{
Grid* pGride = pManager->GetGrid();
Output* pOut = pGride->GetOutput();
Input* pIn = pGride->GetInput();
pOut->PrintMessage("Please Enter File Name: ");
filename = pIn->GetSrting(pOut) + ".txt"; //to get the file from the user and change it the file to txt
pOut->ClearStatusBar();
}
void Save::Execute()
{
ReadActionParameters(); //to read the filename
ofstream outfile(filename, ios::out);
Grid* pGride = pManager->GetGrid();
if (!outfile.is_open()) //to check if the file is opened or not
{
pGride->PrintErrorMessage("Error: Could not open file ");
return;
}
pGride->SaveAll(outfile, filename, Flags);
pGride->SaveAll(outfile, filename, WaterPits);
pGride->SaveAll(outfile, filename, DangerZones);
pGride->SaveAll(outfile, filename, Belts);
pGride->SaveAll(outfile, filename, Workshops);
pGride->SaveAll(outfile, filename, Antennas);
pGride->SaveAll(outfile, filename, RotatingGears);
outfile.close();
pGride->GetOutput()->PrintMessage("Grid Has Been Saved Successfully");
}
Save::~Save()
{
}