-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·61 lines (51 loc) · 1.34 KB
/
main.cpp
File metadata and controls
executable file
·61 lines (51 loc) · 1.34 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
/*
* Copyright 2023 University of Michigan EECS183
*
* main.cpp
* Project UID 848fee0125dbb5eb53ed294f20dbef81
*
* Final Project - Elevators
*/
#include <iostream>
#include <fstream>
#include "Utility.h"
#include "Game.h"
using namespace std;
void start_tests();
int main() {
Game game;
game.printWelcomeMenu();
IntroChoice introChoice = game.getIntroChoice();
string eventSourceFilename = "";
switch (introChoice) {
case IntroChoice::Run_Tests: {
start_tests();
return 0;
}
case IntroChoice::Load: {
eventSourceFilename = LOAD_FILENAME;
break;
}
case IntroChoice::New: {
eventSourceFilename = NEW_FILENAME;
break;
}
default:
throw runtime_error("ERROR: Invalid menu choice detected");
break;
}
ifstream inputFile(eventSourceFilename);
ofstream gameOutput(GAME_INPUT_FILENAME);
string line;
while (getline(inputFile, line)) {
gameOutput << line;
if (!inputFile.eof()) {
gameOutput << "\n";
}
}
gameOutput.close();
inputFile.close();
inputFile.open(GAME_INPUT_FILENAME);
game.playGame(game.getAIChoice() == AIChoice::AI, inputFile);
return 0;
}