-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab4.cpp
executable file
·57 lines (51 loc) · 1.44 KB
/
lab4.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
B// lab4.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <regex>
#include <iomanip> // std::setw
#include <memory> // shared_ptr
using namespace std;
#include "Lab4.h"
#include "GamePiece.h"
#include "GameBase.h"
int usage(const string &name, const string info) {
cout << info << endl;
cout << "Usage: ";
// iterate through file name and print out each character
for (auto c : name) {
cout << c;
}
cout << " gameName player1 player2" << endl;
cout << " * list names only for multiplayer game" << endl;
return failure_command_line_arguments;
}
int main(int argc, char *argv[])
{
try {
GameBase::checkArguments(argc, argv);
auto sp = GameBase::instance();
if (sp == nullptr || (strcmp(argv[gameName], "NineAlmonds") && strcmp(argv[gameName], "MagicSquare") && strcmp(argv[gameName], "Reversi"))) {
string programInfo = "Please run the program as follows:";
usage(argv[programName], programInfo);
}
else {
return sp->play();
}
}
catch (flags e) {
if (e == failure_command_line_arguments || e == incorrect_name) {
string programInfo = "Please run the program as follows:";
return usage(argv[programName], programInfo);
}
else return e;
}
catch (...) {
return failure_bad_alloc_exception;
}
return success;
}