-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
83 lines (79 loc) · 1.62 KB
/
main.cpp
File metadata and controls
83 lines (79 loc) · 1.62 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "Miner.h"
#include "Gold_Mine.h"
#include "Town_Hall.h"
#include <cmath>
#include "Cart_Point.h"
#include "Cart_Vector.h"
#include <cctype>
#include "Model.h"
#include "Game_Object.h"
#include "View.h"
#include "Person.h"
#include "Game_Command.h"
#include <iostream>
using namespace std;
#include <string>
int main()
{
char terminator;
terminator='k';
//default move commands
Game_Command m, w, s, r, g, a, l;
//sets up the default board
View v1;
v1=View();
Model model=Model();
model.show_status();
//creates a while loop until the person wants to quit
while (terminator != 'q')
{
model.display(v1);
cout<< "\nEnter command: ";
cin>>terminator;
if ((isalpha(terminator)) && (cin.good()))
{
switch (terminator)
{
case 'm': //moves the object
m.move_function(model);
break;
case 'w': //works the object
w.work_function(model);
break;
case 's': //stops the object
s.stop_function(model);
break;
case 'r': //runs the object once
r.run_function(model);
break;
case 'g': //causes run to happen 5 times
g.go_function(model);
break;
case 'a': //causes an object to attack
a.attack_function(model);
break;
case 'l': //lists all the objects statuses
l.list_function(model);
break;
case 'q': //exits the program
terminator='q';
cout<< "Terminating program."<< endl;
model.~Model();
break;
default:
cout<< "That command doesn't exist\n"<< endl;
break;
}
}
else if (cin.fail())
{
cin.clear();
cout<< "Not a valid command"<< endl;
}
else
{
cout<< "Not a valid command."<< endl;
}
}
return 0;
}