-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandomGeneration.h
33 lines (31 loc) · 995 Bytes
/
randomGeneration.h
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
//
// Created by alexi on 10/23/2020.
//
#ifndef ELEVATORSIMPROJECT_RANDOMGENERATION_H
#define ELEVATORSIMPROJECT_RANDOMGENERATION_H
#include "dataStructures.h"
#include <stdlib.h>
struct passengerGroup generatePassenger(int currentTime, int startFloor){
struct passengerGroup toReturn;
toReturn.numPassengers = (rand() % 10) + 1;
toReturn.startFloor = startFloor;
//toReturn.startFloor = 3;
toReturn.endFloor = (rand() % 8) + 1;
//toReturn.endFloor = rand() % 2 + 1;
//toReturn.endFloor = 1;
toReturn.generatedTime = currentTime;
toReturn.completed = false;
toReturn.inProgress = false;
while(toReturn.startFloor == toReturn.endFloor){
toReturn.startFloor = (rand() % 8) + 1;
toReturn.endFloor = (rand() % 8) + 1;
}
if(toReturn.startFloor > toReturn.endFloor){
toReturn.direction = false;
}
else{
toReturn.direction = true;
}
return toReturn;
}
#endif //ELEVATORSIMPROJECT_RANDOMGENERATION_H