-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
124 lines (107 loc) · 1.85 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include<iostream>
#include <typeinfo>
#include <string>
using namespace std;
#include "Cart_Point.h"
#include "Cart_Vector.h"
#include "Astronaut.h"
#include "Oxygen_Depot.h"
#include "Space_Station.h"
#include "Person.h"
#include "View.h"
#include "Model.h"
#include "Game_Command.h"
#include "Input_Handling.h"
int main()
{
/*cout << "EC327: Introduction to Software Engineering" << endl;
cout << "Fall 2017" << endl;
cout << "Programming Assignment 3" << endl;
*/
cout << "Welcome to Alien Invasion!" << endl;
cout << "Created by Yan Yan Huang" << endl;
cout << "Select a command to begin." << endl;
Model m1;
View v1;
char command;
m1.show_status();
m1.display(v1);
while(command != 'q')
{
try{
//Asks the user for a command
cout << "Enter a command: ";
cin >> command;
switch(command)
{
case 'm':
{
do_move_command(m1);
break;
}
case 'w':
{
do_work_a_depot_command(m1);
break;
}
case 'd':
{
do_deposit_moonstones_command(m1);
break;
}
case 's':
{
do_stop_command(m1);
break;
}
case 'l':
{
do_lock_in_at_a_station_command(m1);
break;
}
case 'g':
{
do_go_command(m1);
m1.show_status();
m1.display(v1);
break;
}
case 'r':
{
do_run_command(m1);
m1.show_status();
m1.display(v1);
break;
}
case 'a':
{
do_attack_command(m1);
break;
}
case 'n':
{
handle_new_command(m1);
break;
}
default:
{
if(command != 'q')
{
cin.clear();
cin.ignore();
throw Invalid_Input("Illegal Format");
}
}
} //end of switch
}//try end
catch(Invalid_Input& except)
{
cout << "Invalid Input - " << except.msg_ptr << endl;
}
} //end of while loop
if(command == 'q')
{
do_quit_command(m1);
}
return 0;
}