-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
44 lines (39 loc) · 931 Bytes
/
main.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
// Copyright 2020 Chou, Dechathaweewat, Hollis-London
#include <fstream>
#include <iostream>
#include <sstream>
#include "Controller.h"
class Args {
public:
const int args_length = 3;
const std::string seed_flag = "-s";
const int seed_flag_index = 1;
Args(int argc, char** argv);
int seed;
bool valid = true;
};
Args::Args(int argc, char** argv) {
if (argc != args_length || argv[seed_flag_index] != seed_flag) {
this->valid = false;
} else {
try {
std::stringstream seed(argv[2]);
seed >> this->seed;
} catch (...) {
this->valid = false;
}
}
if (!this->valid) {
std::cout << "Usage: \n " << argv[0] << " -s <seed>" << std::endl;
}
}
int main(int argc, char** argv) {
Args args(argc, argv);
if (args.valid) {
// Open a log file for output
std::ofstream logfile("log.txt");
Controller ctrl(args.seed);
ctrl.MainMenu();
logfile.close();
}
}