-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
169 lines (160 loc) · 4.74 KB
/
main.cpp
File metadata and controls
169 lines (160 loc) · 4.74 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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include "string"
#include <array>
#include "misc.h"
#include <future>
#include <pthread.h>
#include <chrono>
#include <curses.h>
using namespace std;
// Creates instances of lifts that operate in building
class lift {
private:
unsigned int liftSize = 0;
public:
void setLiftSize(unsigned int size){
liftSize = size;
}
void showLiftParams(){
cout << liftSize << endl;
}
};
// Stores some parameters for the building we operate in
class building {
private:
unsigned int numOfPeople = 0;
unsigned int numOfStories = 0;
public:
void setNumOfPeople(unsigned int people_num){
numOfPeople = people_num;
}
void setStoriesNum( unsigned int stories_num){
numOfStories = stories_num;
}
};
char userInt(){
initscr();
timeout(-1);
int c = getch();
//endwin();
return c;
}
void startLifts() {
cout << "Hey there, lifts started" << endl;
while (userInt() != 0){
timeout(3000);
cout << "here we float" << endl;
}
exit(0);
}
bool checkUserInput(int questionNo, string input) {
switch (questionNo) {
// Start the initialisation process for lifts?
case 0:
if (input == "Y" || input == "y") {
return true;
}
// Number of lifts
case 1:
cout << stoi(input) <<endl;
if (stoi(input) >= 1 && stoi(input) <= 100) {
return true;
}
// Lift size (in number of people)
case 2:
if (stoi(input) >= 3 && stoi(input) <= 16) {
return true;
}
// Number of people in building
case 3:
if (stoi(input) >= 10 && stoi(input) <= 1000) {
return true;
}
//Number of levels in building
case 4:
if (stoi(input) >= 2 && stoi(input) <= 500) {
return true;
}
}
return false;
}
int main() {
startLifts();
cout << getPersonWeight(70.0, 20.0, 20.0, 200.0) << endl;
bool startLifts_flag = true;
string userInput;
string numOfLifts;
unsigned int numOfStories;
unsigned int numOfPeople;
lift L[16];
while (startLifts_flag) {
for (int i = 0; i <= 4; i++) {
if (i == 0) {
cout << "Start lift initialisation?(Y/N)" << endl;
cin >> userInput;
if (checkUserInput(i, userInput)) {
cout << "Accepted" << endl;
} else {
cout << "Parameter declined, try again" << endl;
break;
}
}
if (i == 1) {
cout << "Enter number of lifts (1 to 16)" << endl;
cin >> numOfLifts;
if (checkUserInput(i, numOfLifts)) {
cout << "Accepted" << endl;
lift L[stoi(numOfLifts)]; // create an array of lift objects
} else {
cout << "Parameter declined, try again" << endl;
break;
}
}
if (i == 2) {
cout << "Enter sizes of lifts (1 to 16)" << endl;
for (int i = 1; i <= stoi(numOfLifts); i++) {
cout << "Enter size of lift " << i << endl;
cin >> userInput;
if (checkUserInput(i, userInput)) {
cout << "Accepted" << endl;
L[i].setLiftSize(stoi(userInput));
} else {
cout << "Parameter declined, try again" << endl;
break;
}
}
}
if (i == 3) {
cout << "Enter number of people in building" << endl;
cin >> userInput;
if (checkUserInput(i, userInput)) {
cout << "Accepted" << endl;
numOfPeople = stoi(userInput);
} else {
cout << "Parameter declined, try again" << endl;
break;
}
}
if (i == 4) {
cout << "Enter number of stories in building" << endl;
cin >> userInput;
if (checkUserInput(i, userInput)) {
cout << "Accepted" << endl;
numOfStories = stoi(userInput);
}
else {
cout << "Parameter declined, try again" << endl;
break;
}
}
}
startLifts_flag = false;
}
for (int i = 0; i <= stoi(numOfLifts); i++) {
L[i].showLiftParams();
}
startLifts();
return 0;
}