-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduleFlight.cpp
67 lines (56 loc) · 1.38 KB
/
scheduleFlight.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: <Taylor Roozen>
Program: <scheduleFlight.cpp>
Last Modified: <11/30/2016>
Description: This program pulls the information from 'flight.in' a file
containing flight inputs, schedule requests, and flight adjustments. It
sends that information to the ATC class one line at a time. It then gets
the updated schduling information from the ATC class, and prints it to the
output file, flight.out.
*/
#include "flight.h"
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
int main()
{
int numFlights, numCommands, lineIdx;
string line, newLine;
ATC flightScheduler;
bool streaming = true;
ifstream infile("flight.in");
ofstream outfile("flight.out");
if(getline(infile, line))
{
istringstream iss(line);
iss >> numFlights >> numCommands;
}
lineIdx = 1;
while (getline(infile, line))
{
if (lineIdx <= numFlights)
{
flightScheduler.inputFlight(line, lineIdx);
}
else
{
flightScheduler.processCommands(line, lineIdx);
}
lineIdx++;
}
while (streaming)
{
newLine = flightScheduler.generateLine();
if (newLine != "END")
outfile << newLine << '\n';
else
streaming = false;
}
infile.close();
outfile.close();
cout << "Schedule Generated." << endl;
return 0;
}