-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
55 lines (49 loc) · 1.34 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
#include <iostream>
#include "lift.h"
int main(int argc, char **argv)
{
uint number;
double height, speed, delay;
if (argc < 5) {
std::cerr << "Usage: " << argv[0] << " <floors> <height> <speed> <delay>" << std::endl;
return 1;
}
number = (uint)atoi(argv[1]);
if(number <5 && number > 20)
std::cerr << "Floors number should be between 5 and 20" << std::endl;
height = atof(argv[2]);
speed = atof(argv[3]);
delay = atof(argv[4]);
Lift lift(number, height, speed, delay);
std::cout << "Enter 0 floor to exit" << std::endl;
for(;;) {
uint floor;
bool inside = false;
char type;
std::cout << "Call lift from entrance hall (press 'e', Enter) or "
"push button inside (press 'i', Enter) lift:";
std::cin >> type;
switch (type) {
case 'i':
std::cout << "Push button number:";
inside = true;
break;
case 'e':
default:
std::cout << "Call lift from floor:";
break;
case '0':
lift.Exit();
return 0;
break;
}
std::cin >> floor;
if(floor != 0) {
lift.SendCommand(floor, inside);
} else {
lift.Exit();
return 0;
}
}
return 0;
}