├── src ├── Floor.cpp ├── Elevator.cpp ├── Passenger.cpp ├── Simulation.cpp ├── PassengerList.cpp ├── SimulationTime.cpp ├── Elevators.cpp ├── stdafx.cpp ├── targetver.h ├── stdafx.h ├── SimulationTime.h ├── Floor.h ├── Simulation.h ├── PassengerList.h ├── Elevator.h └── Passenger.h ├── res ├── results.png ├── simulation.png ├── elevatordata.png └── elevators.csv ├── win32 └── elevators.exe ├── LICENSE └── README.md /src/Floor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donnemartin/elevator-simulator/HEAD/src/Floor.cpp -------------------------------------------------------------------------------- /res/results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donnemartin/elevator-simulator/HEAD/res/results.png -------------------------------------------------------------------------------- /src/Elevator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donnemartin/elevator-simulator/HEAD/src/Elevator.cpp -------------------------------------------------------------------------------- /res/simulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donnemartin/elevator-simulator/HEAD/res/simulation.png -------------------------------------------------------------------------------- /src/Passenger.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donnemartin/elevator-simulator/HEAD/src/Passenger.cpp -------------------------------------------------------------------------------- /src/Simulation.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donnemartin/elevator-simulator/HEAD/src/Simulation.cpp -------------------------------------------------------------------------------- /res/elevatordata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donnemartin/elevator-simulator/HEAD/res/elevatordata.png -------------------------------------------------------------------------------- /src/PassengerList.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donnemartin/elevator-simulator/HEAD/src/PassengerList.cpp -------------------------------------------------------------------------------- /win32/elevators.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donnemartin/elevator-simulator/HEAD/win32/elevators.exe -------------------------------------------------------------------------------- /src/SimulationTime.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/donnemartin/elevator-simulator/HEAD/src/SimulationTime.cpp -------------------------------------------------------------------------------- /src/Elevators.cpp: -------------------------------------------------------------------------------- 1 | // Elevators.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | -------------------------------------------------------------------------------- /src/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // Elevators.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /src/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Donne Martin 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | elevatorsimulator 2 | ============ 3 | 4 | Simulates four elevators available to take passengers up and down the floors of a 100 floor building, written in C++. 5 | 6 | Simulation mechanics: 7 | 8 | * There are 4 elevators available to take passengers up and down the floors of a 100 floor building. 9 | * Each Elevator can be stopped, stopping, moving up, or moving down. 10 | * It takes an elevator 2 seconds of stopping to be stopped. 11 | * It takes each elevator 10 seconds of moving to move between each floor. 12 | * There is a maximum of 8 passengers allowed in a single elevator. 13 | * The elevator data file determines when passengers ask for an elevator, their starting floor, and their destination floor. 14 | * A passenger arrives at the start floor at the start fime, waits for the elevator to arrive and stays on the elevator until arriving at the end floor. 15 | * When a elevator arrives at a floor, it picks up all of the passengers waiting at the floor, up to the maximum capacity of 8, and then starts moving to the End Floors. 16 | * Passengers are queued waiting, if necessary, for elevators. 17 | * The simulation performs one loop each simulated second. 18 | * During each loop, each object decides what to do. 19 | * If stopped and current time is equal to or greater than the next start time, the elevator either begins moving up or moving down depending on the direction needed to pick up the passenger. 20 | * If moving up or moving down and there are one or more passengers waiting at a floor along the way, or if there are current passengers with end floor being the current floor, it begins stopping. 21 | * When stopped at a floor, if there are any passengers in the elevator with that end Floor as a destination, it discharges the passengers. Then, if there are any passengers with that floor as their start Floor it picks up passengers up to the capacity of the elevator. 22 | * Only one elevator can pick up a passenger. 23 | * There is no central controller of elevators as each elevator is making its own decisions as to which passengers to pick up and discharge, therefore there are no conflicts. 24 | 25 | The simulation implements an elevator solution then determines the average wait time and the average travel time it takes for 26 | passengers. The simulation is run twice, one for each elevator taking 10 seconds to move between each floor, and the other for each elevator taking 5 seconds instead. For the second run, the simulation determines the % reduction of average wait time and the % reduction of average travel time for passengers. 27 | 28 | ##License 29 | 30 | Copyright 2014 Donne Martin 31 | 32 | Licensed under the Apache License, Version 2.0 (the "License"); 33 | you may not use this file except in compliance with the License. 34 | You may obtain a copy of the License at 35 | 36 | http://www.apache.org/licenses/LICENSE-2.0 37 | 38 | Unless required by applicable law or agreed to in writing, software 39 | distributed under the License is distributed on an "AS IS" BASIS, 40 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 41 | See the License for the specific language governing permissions and 42 | limitations under the License. 43 | 44 | Elevator data: 45 | 46 | ![alt tag](https://raw.githubusercontent.com/donnemartin/elevatorsimulator/master/res/elevatordata.png) 47 | 48 | Simulation run snippet: 49 | 50 | ![alt tag](https://raw.githubusercontent.com/donnemartin/elevatorsimulator/master/res/simulation.png) 51 | 52 | Simulation results: 53 | 54 | ![alt tag](https://raw.githubusercontent.com/donnemartin/elevatorsimulator/master/res/results.png) -------------------------------------------------------------------------------- /src/SimulationTime.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // 3 | // File Name: SimulationTime.h 4 | // 5 | // File Overview: Represents a SimulationTime (singleton) 6 | // 7 | //****************************************************************************** 8 | // 9 | // Revision History: 10 | // 11 | // Date Author Description 12 | // 7.23.11 Donne Martin Added class 13 | //****************************************************************************** 14 | 15 | #ifndef SimulationTime_h 16 | #define SimulationTime_h 17 | 18 | //****************************************************************************** 19 | // 20 | // Class: SimulationTime 21 | // 22 | // Revision History: 23 | // 24 | // Date Author Description 25 | // 7.23.11 Donne Martin Added class 26 | // 27 | // Notes: None 28 | // 29 | //****************************************************************************** 30 | class SimulationTime 31 | { 32 | public: 33 | 34 | //*************************************************************************** 35 | // Function : destructor 36 | // Description : None 37 | // Constraints : None 38 | //*************************************************************************** 39 | virtual ~SimulationTime(); 40 | 41 | // Member functions in alphabetical order 42 | 43 | //*************************************************************************** 44 | // Function : getInstance 45 | // Description : Retrieves the single instance of the class 46 | // Constraints : None 47 | //*************************************************************************** 48 | inline static SimulationTime* getInstance(); 49 | 50 | //*************************************************************************** 51 | // Function : getTime 52 | // Description : Accessor for time 53 | // Constraints : None 54 | //*************************************************************************** 55 | inline int getTime() const; 56 | 57 | //*************************************************************************** 58 | // Function : incrementTime 59 | // Description : Increments the time by one 60 | // Constraints : None 61 | //*************************************************************************** 62 | inline void incrementTime(); 63 | 64 | //*************************************************************************** 65 | // Function : setTime 66 | // Description : Mutator for time 67 | // Constraints : None 68 | //*************************************************************************** 69 | inline void setTime(const int time); 70 | 71 | //*************************************************************************** 72 | // public Class Attributes 73 | //*************************************************************************** 74 | 75 | private: 76 | 77 | //*************************************************************************** 78 | // Function : constructor 79 | // Description : None 80 | // Constraints : None 81 | //*************************************************************************** 82 | SimulationTime(); 83 | 84 | static SimulationTime* instancePtr; // Pointer to itself (singleton) 85 | int time; // Simulation time 86 | }; // end class SimulationTime 87 | 88 | //****************************************************************************** 89 | // Function : getInstance 90 | // Process : Retrieve the single instance of the class if it exist 91 | // Else, create it, then return 92 | // Notes : None 93 | // 94 | // Revision History: 95 | // 96 | // Date Author Description 97 | // 7.23.11 Donne Martin Added function 98 | //****************************************************************************** 99 | inline SimulationTime* SimulationTime::getInstance() 100 | { 101 | if (!instancePtr) 102 | { 103 | instancePtr = new SimulationTime; 104 | } 105 | 106 | return instancePtr; 107 | } 108 | 109 | //****************************************************************************** 110 | // Function : getTime 111 | // Process : Accessor for time 112 | // Notes : None 113 | // 114 | // Revision History: 115 | // 116 | // Date Author Description 117 | // 7.23.11 Donne Martin Added function 118 | //****************************************************************************** 119 | inline int SimulationTime::getTime() const 120 | { 121 | return time; 122 | } 123 | 124 | //****************************************************************************** 125 | // Function : incrementTime 126 | // Process : Increment the time by one 127 | // Notes : None 128 | // 129 | // Revision History: 130 | // 131 | // Date Author Description 132 | // 7.23.11 Donne Martin Added function 133 | //****************************************************************************** 134 | inline void SimulationTime::incrementTime() 135 | { 136 | this->time++; 137 | } 138 | 139 | //****************************************************************************** 140 | // Function : setTime 141 | // Process : Mutator for time 142 | // Notes : None 143 | // 144 | // Revision History: 145 | // 146 | // Date Author Description 147 | // 7.23.11 Donne Martin Added function 148 | //****************************************************************************** 149 | inline void SimulationTime::setTime(const int time) 150 | { 151 | this->time = time; 152 | } 153 | 154 | #endif // SimulationTime_h 155 | -------------------------------------------------------------------------------- /src/Floor.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // 3 | // File Name: Floor.h 4 | // 5 | // File Overview: Represents a Floor 6 | // 7 | //****************************************************************************** 8 | // 9 | // Revision History: 10 | // 11 | // Date Author Description 12 | // 7.23.11 Donne Martin Added class 13 | //****************************************************************************** 14 | 15 | #ifndef Floor_h 16 | #define Floor_h 17 | 18 | using namespace std; 19 | 20 | //****************************************************************************** 21 | // 22 | // Class: Floor 23 | // 24 | // Revision History: 25 | // 26 | // Date Author Description 27 | // 7.23.11 Donne Martin Added class 28 | // 29 | // Notes: None 30 | // 31 | //****************************************************************************** 32 | class Floor 33 | { 34 | public: 35 | 36 | //*************************************************************************** 37 | // Function : constructor 38 | // Description : None 39 | // Constraints : None 40 | //*************************************************************************** 41 | Floor(); 42 | 43 | //*************************************************************************** 44 | // Function : destructor 45 | // Description : None 46 | // Constraints : None 47 | //*************************************************************************** 48 | virtual ~Floor(); 49 | 50 | // Member functions in alphabetical order 51 | 52 | //*************************************************************************** 53 | // Function : decrementFloorNumber 54 | // Description : Decrements the floor number by one 55 | // Constraints : None 56 | //*************************************************************************** 57 | inline void decrementFloorNumber(); 58 | 59 | //*************************************************************************** 60 | // Function : getNumber 61 | // Description : Accessor for number 62 | // Constraints : None 63 | //*************************************************************************** 64 | inline int getNumber() const; 65 | 66 | //*************************************************************************** 67 | // Function : incrementFloorNumber 68 | // Description : Increments the floor number by one 69 | // Constraints : None 70 | //*************************************************************************** 71 | inline void incrementFloorNumber(); 72 | 73 | //*************************************************************************** 74 | // Function : operator< 75 | // Description : Overrides operator< to work with floor's number 76 | // Constraints : None 77 | //*************************************************************************** 78 | inline bool operator<(const Floor& floor); 79 | 80 | //*************************************************************************** 81 | // Function : setNumber 82 | // Description : Mutator for number 83 | // Constraints : None 84 | //*************************************************************************** 85 | inline void setNumber(const int number); 86 | 87 | //*************************************************************************** 88 | // public Class Attributes 89 | //*************************************************************************** 90 | static const int START_FLOOR = 1; // Start at the first floor 91 | 92 | private: 93 | int number; // Floor number 94 | 95 | }; // end class Floor 96 | 97 | //****************************************************************************** 98 | // Function : decrementFloorNumber 99 | // Process : Decrement the floor number by one 100 | // Notes : None 101 | // 102 | // Revision History: 103 | // 104 | // Date Author Description 105 | // 7.23.11 Donne Martin Added function 106 | //****************************************************************************** 107 | inline void Floor::decrementFloorNumber() 108 | { 109 | this->number--; } 110 | 111 | //****************************************************************************** 112 | // Function : getNumber 113 | // Process : Accessor for number 114 | // Notes : None 115 | // 116 | // Revision History: 117 | // 118 | // Date Author Description 119 | // 7.23.11 Donne Martin Added function 120 | //****************************************************************************** 121 | inline int Floor::getNumber() const 122 | { 123 | return this->number; } 124 | 125 | //****************************************************************************** 126 | // Function : incrementFloorNumber 127 | // Process : Increment the floor number by one 128 | // Notes : None 129 | // 130 | // Revision History: 131 | // 132 | // Date Author Description 133 | // 7.23.11 Donne Martin Added function 134 | //****************************************************************************** 135 | inline void Floor::incrementFloorNumber() 136 | { 137 | this->number++; } 138 | 139 | //****************************************************************************** 140 | // Function : operator< 141 | // Process : Override operator< to work with floor's number 142 | // Notes : None 143 | // 144 | // Revision History: 145 | // 146 | // Date Author Description 147 | // 7.23.11 Donne Martin Added function 148 | //****************************************************************************** 149 | inline bool Floor::operator<(const Floor& floor) 150 | { 151 | return floor.getNumber() < this->getNumber(); 152 | } 153 | 154 | //****************************************************************************** 155 | // Function : setNumber 156 | // Process : Mutator for number 157 | // Notes : None 158 | // 159 | // Revision History: 160 | // 161 | // Date Author Description 162 | // 7.23.11 Donne Martin Added function 163 | //****************************************************************************** 164 | inline void Floor::setNumber(const int number) 165 | { 166 | this->number = number; } 167 | 168 | #endif // Floor_h 169 | -------------------------------------------------------------------------------- /res/elevators.csv: -------------------------------------------------------------------------------- 1 | Start Time(s),Start Floor,End Floor 2 | 41,54,55 3 | 43,30,74 4 | 88,87,32 5 | 93,35,55 6 | 121,35,4 7 | 168,63,22 8 | 205,20,92 9 | 211,23,32 10 | 268,48,72 11 | 325,70,69 12 | 380,57,48 13 | 434,40,22 14 | 447,7,98 15 | 454,35,49 16 | 495,55,68 17 | 550,27,58 18 | 557,19,96 19 | 590,87,54 20 | 616,96,74 21 | 645,95,35 22 | 649,40,5 23 | 707,32,13 24 | 729,11,44 25 | 749,63,79 26 | 804,62,5 27 | 813,3,91 28 | 836,16,43 29 | 849,85,27 30 | 860,95,38 31 | 885,92,15 32 | 944,42,36 33 | 990,13,72 34 | 1012,51,67 35 | 1027,92,26 36 | 1049,25,52 37 | 1053,18,65 38 | 1086,17,38 39 | 1113,3,68 40 | 1124,10,84 41 | 1160,46,4 42 | 1200,71,65 43 | 1235,98,32 44 | 1286,13,22 45 | 1344,35,29 46 | 1400,64,1 47 | 1437,65,87 48 | 1466,11,13 49 | 1468,36,14 50 | 1492,5,55 51 | 1495,96,68 52 | 1507,78,22 53 | 1527,32,28 54 | 1545,88,22 55 | 1581,89,58 56 | 1627,1,67 57 | 1656,92,49 58 | 1694,85,26 59 | 1749,28,31 60 | 1755,69,95 61 | 1812,59,8 62 | 1823,65,62 63 | 1862,55,34 64 | 1890,74,72 65 | 1921,55,41 66 | 1952,36,84 67 | 1994,93,2 68 | 2003,86,82 69 | 2032,45,84 70 | 2073,98,52 71 | 2122,50,38 72 | 2131,54,73 73 | 2175,33,76 74 | 2214,30,40 75 | 2241,81,97 76 | 2250,48,95 77 | 2296,60,67 78 | 2344,26,93 79 | 2365,92,79 80 | 2375,36,60 81 | 2403,24,61 82 | 2422,87,56 83 | 2465,45,46 84 | 2498,30,93 85 | 2553,57,51 86 | 2576,38,63 87 | 2582,32,23 88 | 2626,93,89 89 | 2674,49,46 90 | 2721,43,91 91 | 2769,7,67 92 | 2816,81,60 93 | 2838,41,84 94 | 2865,94,94 95 | 2917,93,5 96 | 2941,39,54 97 | 2963,79,99 98 | 2994,27,21 99 | 3001,36,75 100 | 3014,97,32 101 | 3027,36,56 102 | 3032,18,86 103 | 3067,29,91 104 | 3068,82,43 105 | 3114,87,7 106 | 3125,74,75 107 | 3161,42,33 108 | 3207,19,44 109 | 3245,63,66 110 | 3271,91,29 111 | 3287,20,58 112 | 3342,53,38 113 | 3358,12,5 114 | 3375,93,20 115 | 3412,45,72 116 | 3434,33,21 117 | 3493,12,85 118 | 3551,56,5 119 | 3560,72,56 120 | 3605,44,90 121 | 3611,8,14 122 | 3646,63,62 123 | 3688,37,95 124 | 3707,88,21 125 | 3717,90,40 126 | 3721,17,1 127 | 3724,17,34 128 | 3733,89,44 129 | 3776,98,70 130 | 3835,25,33 131 | 3866,5,40 132 | 3888,9,34 133 | 3913,57,38 134 | 3973,78,68 135 | 4004,75,84 136 | 4045,91,3 137 | 4084,53,15 138 | 4097,44,92 139 | 4156,37,15 140 | 4197,36,38 141 | 4213,7,92 142 | 4264,89,52 143 | 4307,75,25 144 | 4311,64,62 145 | 4351,18,35 146 | 4362,74,13 147 | 4386,90,79 148 | 4394,24,83 149 | 4451,34,10 150 | 4496,41,79 151 | 4526,7,56 152 | 4566,20,52 153 | 4603,86,6 154 | 4618,59,35 155 | 4652,28,93 156 | 4659,62,78 157 | 4675,84,69 158 | 4689,71,61 159 | 4730,66,7 160 | 4732,9,98 161 | 4783,81,25 162 | 4785,57,31 163 | 4818,77,50 164 | 4863,49,42 165 | 4909,27,41 166 | 4948,27,89 167 | 4988,88,31 168 | 4993,11,16 169 | 5032,44,20 170 | 5075,89,92 171 | 5098,45,84 172 | 5124,28,42 173 | 5158,41,45 174 | 5168,78,88 175 | 5174,72,7 176 | 5175,82,32 177 | 5194,44,30 178 | 5238,12,48 179 | 5270,33,16 180 | 5314,88,55 181 | 5352,93,86 182 | 5406,57,87 183 | 5463,74,48 184 | 5504,15,74 185 | 5537,45,2 186 | 5568,85,9 187 | 5571,34,89 188 | 5576,4,57 189 | 5632,87,53 190 | 5645,52,19 191 | 5658,40,7 192 | 5683,26,9 193 | 5696,77,61 194 | 5746,3,10 195 | 5769,34,45 196 | 5804,83,49 197 | 5830,24,28 198 | 5872,24,84 199 | 5924,80,52 200 | 5952,9,37 201 | 5990,37,53 202 | 5994,84,65 203 | 6017,31,24 204 | 6055,2,51 205 | 6065,2,17 206 | 6118,23,86 207 | 6120,97,86 208 | 6166,57,70 209 | 6170,17,48 210 | 6216,50,9 211 | 6268,9,18 212 | 6319,43,95 213 | 6333,94,63 214 | 6388,35,15 215 | 6392,43,72 216 | 6439,5,85 217 | 6460,47,81 218 | 6489,66,91 219 | 6528,25,32 220 | 6545,99,18 221 | 6585,79,67 222 | 6600,83,68 223 | 6634,41,71 224 | 6684,51,79 225 | 6735,49,76 226 | 6770,23,52 227 | 6786,90,32 228 | 6796,40,39 229 | 6854,16,58 230 | 6859,54,28 231 | 6907,82,50 232 | 6939,72,62 233 | 6973,98,11 234 | 6991,55,67 235 | 7050,93,65 236 | 7073,52,47 237 | 7131,24,57 238 | 7153,4,35 239 | 7167,41,7 240 | 7167,61,98 241 | 7182,54,72 242 | 7241,99,84 243 | 7244,3,77 244 | 7285,67,55 245 | 7328,25,95 246 | 7377,67,28 247 | 7419,8,1 248 | 7420,48,23 249 | 7453,75,2 250 | 7476,54,34 251 | 7505,30,9 252 | 7556,53,85 253 | 7599,36,15 254 | 7637,92,30 255 | 7655,50,37 256 | 7704,50,91 257 | 7712,64,66 258 | 7767,16,91 259 | 7821,94,21 260 | 7826,99,56 261 | 7855,98,90 262 | 7893,51,28 263 | 7910,85,50 264 | 7938,39,33 265 | 7963,15,8 266 | 7974,92,90 267 | 7996,74,8 268 | 8052,36,16 269 | 8071,2,56 270 | 8086,14,31 271 | 8086,53,47 272 | 8123,36,97 273 | 8167,48,2 274 | 8201,60,41 275 | 8245,37,64 276 | 8282,83,95 277 | 8296,24,20 278 | 8331,51,37 279 | 8372,74,27 280 | 8398,36,91 281 | 8431,98,19 282 | 8489,77,73 283 | 8537,9,70 284 | 8582,89,36 285 | 8630,91,72 286 | 8677,44,19 287 | 8734,15,96 288 | 8770,73,77 289 | 8816,3,95 290 | 8835,89,58 291 | 8841,99,63 292 | 8864,65,23 293 | 8902,92,43 294 | 8919,31,4 295 | 8942,87,98 296 | 8960,20,2 297 | 8990,16,7 298 | 9003,7,67 299 | 9047,88,79 300 | 9074,63,88 301 | 9100,63,10 302 | 9105,5,55 303 | 9128,99,29 304 | 9136,82,61 305 | 9162,20,95 306 | 9163,39,89 307 | 9203,39,76 308 | 9224,51,16 309 | 9274,6,2 310 | 9319,32,69 311 | 9364,63,97 312 | 9400,45,3 313 | 9414,51,61 314 | 9469,57,67 315 | 9500,91,87 316 | 9517,70,15 317 | 9573,84,31 318 | 9619,5,51 319 | 9665,92,79 320 | 9704,44,21 321 | 9705,42,29 322 | 9764,74,52 323 | 9805,30,49 324 | 9864,94,52 325 | 9873,83,84 326 | 9922,23,65 327 | 9970,44,22 328 | 10019,38,44 329 | 10026,16,48 330 | 10050,40,96 331 | 10098,14,40 332 | 10138,14,36 333 | 10191,68,24 334 | 10239,63,12 335 | 10255,97,80 336 | 10288,4,51 337 | 10331,80,70 338 | 10390,78,9 339 | 10394,59,63 340 | 10411,54,6 341 | 10451,18,15 342 | 10511,76,65 343 | 10533,76,73 344 | 10546,95,62 345 | 10604,30,29 346 | 10635,51,33 347 | 10695,37,26 348 | 10743,23,99 349 | 10754,68,5 350 | 10790,89,53 351 | 10838,30,67 352 | 10889,21,60 353 | 10902,73,43 354 | 10955,13,67 355 | 11014,21,5 356 | 11040,32,53 357 | 11079,18,37 358 | 11119,53,4 359 | 11119,48,64 360 | 11134,30,69 361 | 11155,73,25 362 | 11182,95,7 363 | 11201,57,39 364 | 11253,57,92 365 | 11258,36,80 366 | 11300,88,75 367 | 11339,18,42 368 | 11364,76,71 369 | 11380,28,18 370 | 11423,76,89 371 | 11457,46,10 372 | 11464,79,14 373 | 11472,73,60 374 | 11488,15,96 375 | 11509,68,33 376 | 11520,52,57 377 | 11577,7,75 378 | 11593,53,93 379 | 11616,20,31 380 | 11636,66,70 381 | 11656,82,26 382 | 11709,28,75 383 | 11732,30,67 384 | 11751,84,75 385 | 11789,49,50 386 | 11798,40,97 387 | 11831,46,42 388 | 11876,71,96 389 | 11906,4,9 390 | 11929,65,92 391 | 11975,2,67 392 | 12023,2,70 393 | 12058,32,52 394 | 12062,1,13 395 | 12118,5,66 396 | 12153,86,6 397 | 12213,10,47 398 | 12265,74,67 399 | 12281,71,20 400 | 12334,13,15 401 | 12386,22,13 402 | 12417,54,78 403 | 12418,81,89 404 | 12427,9,56 405 | 12476,70,48 406 | 12479,32,7 407 | 12516,80,27 408 | 12526,23,19 409 | 12552,23,25 410 | 12592,90,73 411 | 12605,44,9 412 | 12635,46,56 413 | 12637,19,69 414 | 12686,76,25 415 | 12720,13,47 416 | 12740,26,70 417 | 12777,71,78 418 | 12836,77,9 419 | 12871,4,55 420 | 12878,84,64 421 | 12898,11,44 422 | 12935,3,77 423 | 12979,7,59 424 | 13011,56,24 425 | 13046,42,62 426 | 13078,52,47 427 | 13097,12,20 428 | 13109,60,34 429 | 13136,80,64 430 | 13189,93,68 431 | 13189,53,69 432 | 13246,51,48 433 | 13259,91,71 434 | 13271,83,83 435 | 13310,27,81 436 | 13312,65,34 437 | 13342,68,44 438 | 13401,76,1 439 | 13415,36,79 440 | 13444,68,80 441 | 13470,83,3 442 | 13490,91,65 443 | 13522,11,77 444 | 13523,26,6 445 | 13534,15,2 446 | 13553,39,10 447 | 13577,75,41 448 | 13611,65,46 449 | 13629,37,42 450 | 13651,67,93 451 | 13688,61,5 452 | 13722,2,44 453 | 13754,43,30 454 | 13793,27,60 455 | 13805,97,20 456 | 13854,16,88 457 | 13891,44,51 458 | 13935,60,53 459 | 13991,58,9 460 | 14045,52,83 461 | 14103,33,25 462 | 14105,60,60 463 | 14115,15,27 464 | 14121,33,23 465 | 14168,94,93 466 | 14217,63,14 467 | 14240,8,28 468 | 14292,24,74 469 | 14307,72,96 470 | 14343,34,79 471 | 14377,9,92 472 | 14408,74,44 473 | 14423,21,39 474 | 14430,32,21 475 | 14473,34,36 476 | 14530,10,96 477 | 14551,79,86 478 | 14552,30,34 479 | 14569,30,97 480 | 14617,42,83 481 | 14619,73,54 482 | 14644,67,10 483 | 14680,96,46 484 | 14734,17,82 485 | 14763,61,3 486 | 14767,20,79 487 | 14789,39,29 488 | 14845,19,17 489 | 14858,12,40 490 | 14904,22,62 491 | 14937,90,94 492 | 14940,89,19 493 | 14955,85,89 494 | 14960,35,35 495 | 14995,57,67 496 | 15037,50,45 497 | 15071,7,43 498 | 15114,67,23 499 | 15120,8,36 500 | 15122,91,2 501 | 15155,33,62 502 | 15215,42,76 503 | -------------------------------------------------------------------------------- /src/Simulation.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // 3 | // File Name: Simulation.h 4 | // 5 | // File Overview: Represents a Simulation 6 | // 7 | //****************************************************************************** 8 | // 9 | // Revision History: 10 | // 11 | // Date Author Description 12 | // 7.23.11 Donne Martin Added class 13 | //****************************************************************************** 14 | 15 | #ifndef Simulation_h 16 | #define Simulation_h 17 | 18 | #include 19 | #include 20 | #include "Elevator.h" 21 | #include "Floor.h" 22 | #include "Passenger.h" 23 | 24 | using namespace std; 25 | 26 | //****************************************************************************** 27 | // 28 | // Class: Simulation 29 | // 30 | // Revision History: 31 | // 32 | // Date Author Description 33 | // 7.23.11 Donne Martin Added class 34 | // 35 | // Notes: None 36 | // 37 | //****************************************************************************** 38 | class Simulation 39 | { 40 | public: 41 | 42 | //*************************************************************************** 43 | // Function : constructor 44 | // Description : None 45 | // Constraints : None 46 | //*************************************************************************** 47 | Simulation(); 48 | 49 | //*************************************************************************** 50 | // Function : destructor 51 | // Description : None 52 | // Constraints : None 53 | //*************************************************************************** 54 | virtual ~Simulation(); 55 | 56 | // Member functions in alphabetical order 57 | 58 | //*************************************************************************** 59 | // Function : addPassenger 60 | // Description : Adds the passenger to our list of passengers 61 | // Constraints : None 62 | //*************************************************************************** 63 | void addPassenger( 64 | const int startTime, 65 | const Floor& startFloor, 66 | const Floor& endFloor); 67 | 68 | //*************************************************************************** 69 | // Function : areAllPassengersCompleted 70 | // Description : Determines if all passengers have a status of COMPLETED 71 | // Constraints : None 72 | //*************************************************************************** 73 | bool areAllPassengersCompleted() const; 74 | 75 | //*************************************************************************** 76 | // Function : calculateWaitAndTravelTimes 77 | // Description : Calculates the wait and travel times for each passenger 78 | // Constraints : None 79 | //*************************************************************************** 80 | void calculateWaitAndTravelTimes(); 81 | 82 | //*************************************************************************** 83 | // Function : atoiCheckOutOfRange 84 | // Description : Determines if the input number is out of range from atoi 85 | // Constraints : None 86 | //*************************************************************************** 87 | void atoiCheckOutOfRange(const int quantity) const; 88 | 89 | //*************************************************************************** 90 | // Function : getTime 91 | // Description : Accessor for time 92 | // Constraints : None 93 | //*************************************************************************** 94 | inline int getTime() const; 95 | 96 | //*************************************************************************** 97 | // Function : incrementSimulationTime 98 | // Description : Increments the simulation time by one 99 | // Constraints : None 100 | //*************************************************************************** 101 | void incrementSimulationTime(); 102 | 103 | //*************************************************************************** 104 | // Function : loadElevatorDataFromFile 105 | // Description : Loads the data from the elevator file 106 | // Constraints : None 107 | //*************************************************************************** 108 | void loadElevatorDataFromFile(); 109 | 110 | //*************************************************************************** 111 | // Function : outputWaitAndTravelTimeAnalysis 112 | // Description : Outputs the wait and travel times to cout 113 | // Constraints : None 114 | //*************************************************************************** 115 | void outputWaitAndTravelTimeAnalysis() const; 116 | 117 | //*************************************************************************** 118 | // Function : parseLine 119 | // Description : Parses the current line from the elevator data file 120 | // Constraints : None 121 | //*************************************************************************** 122 | void parseLine( 123 | const string& currLine, 124 | int& startTime, 125 | Floor& startFloor, 126 | Floor& endFloor) const; 127 | 128 | //*************************************************************************** 129 | // Function : queuePassengers 130 | // Description : Adds passengers to the queue who have a start time 131 | // equal to the current simulation time 132 | // Constraints : None 133 | //*************************************************************************** 134 | void queuePassengers(); 135 | 136 | //*************************************************************************** 137 | // Function : resetSimulation 138 | // Description : Resets the simulation to allow for another run 139 | // Constraints : None 140 | //*************************************************************************** 141 | void resetSimulation(); 142 | 143 | //*************************************************************************** 144 | // Function : runDefaultElevatorSimulation 145 | // Description : Runs the default set of params for the elevator simulations 146 | // Constraints : None 147 | //*************************************************************************** 148 | void runDefaultElevatorSimulation(); 149 | 150 | //*************************************************************************** 151 | // Function : runSimulation 152 | // Description : Runs the simulation 153 | // Constraints : None 154 | //*************************************************************************** 155 | void runSimulation(int elevatorTimeToNextFloor); 156 | 157 | //*************************************************************************** 158 | // Function : setElevatorDataFile 159 | // Description : Accessor for elevatorDataFile 160 | // Constraints : None 161 | //*************************************************************************** 162 | inline void setElevatorDataFile(const string& elevatorDataFile); 163 | 164 | //*************************************************************************** 165 | // public Class Attributes 166 | //*************************************************************************** 167 | 168 | static const int NUM_ELEVATORS = 4; // Number of elevators 169 | static const int NUM_FLOORS = 100; // Number of floors 170 | 171 | private: 172 | PassengerList* passengerListPtr; // List of Passengers (singleton) 173 | SimulationTime* simulationTimePtr; // Simulation time (singleton) 174 | 175 | string elevatorDataFile; // File name containing the elevator data 176 | 177 | vector elevators; // Vector of elevators 178 | 179 | vector avgWaitTimes; // Vector of avg wait times 180 | vector avgTravelTimes; // Vector of avg travel times 181 | 182 | }; // end class Simulation 183 | 184 | //****************************************************************************** 185 | // Function : getTime 186 | // Process : Accessor for the simulatime time 187 | // Notes : None 188 | // 189 | // Revision History: 190 | // 191 | // Date Author Description 192 | // 7.23.11 Donne Martin Added function 193 | //****************************************************************************** 194 | inline int Simulation::getTime() const 195 | { 196 | return this->simulationTimePtr->getTime(); 197 | } 198 | 199 | //****************************************************************************** 200 | // Function : setElevatorDataFile 201 | // Process : Mutator for elevatorDataFile 202 | // Notes : None 203 | // 204 | // Revision History: 205 | // 206 | // Date Author Description 207 | // 7.23.11 Donne Martin Added function 208 | //****************************************************************************** 209 | inline void Simulation::setElevatorDataFile(const string& elevatorDataFile) 210 | { 211 | this->elevatorDataFile = elevatorDataFile; 212 | } 213 | 214 | #endif // Simulation_h 215 | -------------------------------------------------------------------------------- /src/PassengerList.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // 3 | // File Name: PassengerList.h 4 | // 5 | // File Overview: Represents a PassengerList (singleton) 6 | // 7 | //****************************************************************************** 8 | // 9 | // Revision History: 10 | // 11 | // Date Author Description 12 | // 7.23.11 Donne Martin Added class 13 | //****************************************************************************** 14 | 15 | #ifndef PassengerList_h 16 | #define PassengerList_h 17 | 18 | #include 19 | #include 20 | #include "Passenger.h" 21 | 22 | using namespace std; 23 | 24 | //****************************************************************************** 25 | // 26 | // Class: PassengerList 27 | // 28 | // Revision History: 29 | // 30 | // Date Author Description 31 | // 7.23.11 Donne Martin Added class 32 | // 33 | // Notes: None 34 | // 35 | //****************************************************************************** 36 | class PassengerList 37 | { 38 | public: 39 | 40 | //*************************************************************************** 41 | // Function : destructor 42 | // Description : None 43 | // Constraints : None 44 | //*************************************************************************** 45 | virtual ~PassengerList(); 46 | 47 | // Member functions in alphabetical order 48 | 49 | //*************************************************************************** 50 | // Function : addPassenger 51 | // Description : Adds the passenger to the list 52 | // Constraints : None 53 | //*************************************************************************** 54 | inline void addPassenger(const Passenger& passenger); 55 | 56 | //*************************************************************************** 57 | // Function : getInstance 58 | // Description : Retrieves the single instance of the class 59 | // Constraints : None 60 | //*************************************************************************** 61 | inline static PassengerList* getInstance(); 62 | 63 | //*************************************************************************** 64 | // Function : getNextDestinationPassengerIndex 65 | // Description : Retrieves the next destination passenger matching 66 | // the input criteria 67 | // Constraints : None 68 | //*************************************************************************** 69 | bool getNextDestinationPassengerIndex( 70 | const int time, 71 | const Floor& currentFloor, 72 | const Floor& endFloor, 73 | const Passenger::Status status, 74 | int& passengerIndex); 75 | 76 | //*************************************************************************** 77 | // Function : getPassengerBoardElevatorTimeAt 78 | // Description : Retrieves the board elevator time of the specified passenger 79 | // Constraints : None 80 | //*************************************************************************** 81 | inline int getPassengerBoardElevatorTimeAt(const int index) const; 82 | 83 | //*************************************************************************** 84 | // Function : getPassengerEndFloorNumberAt 85 | // Description : Retrieves the end floor number of the specified passenger 86 | // Constraints : None 87 | //*************************************************************************** 88 | inline int getPassengerEndFloorNumberAt(const int index) const; 89 | 90 | //*************************************************************************** 91 | // Function : getPassengerExitElevatorTimeAt 92 | // Description : Retrieves the exit elevator time of the specified passenger 93 | // Constraints : None 94 | //*************************************************************************** 95 | inline int getPassengerExitElevatorTimeAt(const int index) const; 96 | 97 | //*************************************************************************** 98 | // Function : getPassengerIdAt 99 | // Description : Retrieves the id of the specified passenger 100 | // Constraints : None 101 | //*************************************************************************** 102 | inline int getPassengerIdAt(const int index) const; 103 | 104 | //*************************************************************************** 105 | // Function : getPassengerListSize 106 | // Description : Retrieves the passenger list size 107 | // Constraints : None 108 | //*************************************************************************** 109 | inline int getPassengerListSize() const; 110 | 111 | //*************************************************************************** 112 | // Function : getPassengerStartFloorNumberAt 113 | // Description : Retrieves the start floor number of the specified passenger 114 | // Constraints : None 115 | //*************************************************************************** 116 | inline int getPassengerStartFloorNumberAt(const int index) const; 117 | 118 | //*************************************************************************** 119 | // Function : getPassengerStartTimeAt 120 | // Description : Retrieves the start time of the specified passenger 121 | // Constraints : None 122 | //*************************************************************************** 123 | inline int getPassengerStartTimeAt(const int index) const; 124 | 125 | //*************************************************************************** 126 | // Function : getPassengerStatusAt 127 | // Description : Retrieves the status of the specified passenger 128 | // Constraints : None 129 | //*************************************************************************** 130 | inline Passenger::Status getPassengerStatusAt(const int index) const; 131 | 132 | //*************************************************************************** 133 | // Function : getQueuedPassengersAtFloor 134 | // Description : Retrieves a list of queued passengers at a specified floor 135 | // that matches the input criteria 136 | // Constraints : None 137 | //*************************************************************************** 138 | bool getQueuedPassengersAtFloor( 139 | const int time, 140 | const Floor& currentFloor, 141 | const Passenger::Status status, 142 | const int destPassengerIndex, 143 | vector& nextPassengerIndex); 144 | 145 | //*************************************************************************** 146 | // Function : resetPassengerStatusAndBoardExitTimesAt 147 | // Description : Resets the passenger status and elevator board/exit times 148 | // Constraints : None 149 | //*************************************************************************** 150 | void resetPassengerStatusAndBoardExitTimesAt(const int index); 151 | 152 | //*************************************************************************** 153 | // Function : setPassengerStatusAt 154 | // Description : Sets the status of the specified passenger 155 | // Constraints : None 156 | //*************************************************************************** 157 | inline void setPassengerStatusAt(const int index, Passenger::Status status, const int time); 158 | 159 | //*************************************************************************** 160 | // public Class Attributes 161 | //*************************************************************************** 162 | 163 | private: 164 | 165 | //*************************************************************************** 166 | // Function : constructor 167 | // Description : None 168 | // Constraints : None 169 | //*************************************************************************** 170 | PassengerList(); 171 | 172 | static PassengerList* instancePtr; // Pointer to itself (singleton) 173 | // we are processing 174 | vector passengerList; // List of queued passengers 175 | }; // end class PassengerList 176 | 177 | //****************************************************************************** 178 | // Function : addPassenger 179 | // Process : Add the specified passenger to our list of passengers 180 | // Notes : None 181 | // 182 | // Revision History: 183 | // 184 | // Date Author Description 185 | // 7.23.11 Donne Martin Added function 186 | //****************************************************************************** 187 | inline void PassengerList::addPassenger(const Passenger& passenger) 188 | { 189 | this->passengerList.push_back(passenger); 190 | } 191 | 192 | //****************************************************************************** 193 | // Function : getInstance 194 | // Process : Retrieve the single instance to the class if it exists 195 | // Else, create it, then return 196 | // Notes : None 197 | // 198 | // Revision History: 199 | // 200 | // Date Author Description 201 | // 7.23.11 Donne Martin Added function 202 | //****************************************************************************** 203 | inline PassengerList* PassengerList::getInstance() 204 | { 205 | if (!instancePtr) 206 | { 207 | instancePtr = new PassengerList; 208 | } 209 | 210 | return instancePtr; 211 | } 212 | 213 | //****************************************************************************** 214 | // Function : getPassengerBoardElevatorTimeAt 215 | // Process : Retrieves the board elevator time of the specified passenger 216 | // Notes : None 217 | // 218 | // Revision History: 219 | // 220 | // Date Author Description 221 | // 7.23.11 Donne Martin Added function 222 | //****************************************************************************** 223 | inline int PassengerList::getPassengerBoardElevatorTimeAt(const int index) const 224 | { 225 | return this->passengerList.at(index).getBoardElevatorTime(); 226 | } 227 | 228 | //****************************************************************************** 229 | // Function : getPassengerEndFloorNumberAt 230 | // Process : Retrieves the end floor number of the specified passenger 231 | // Notes : None 232 | // 233 | // Revision History: 234 | // 235 | // Date Author Description 236 | // 7.23.11 Donne Martin Added function 237 | //****************************************************************************** 238 | inline int PassengerList::getPassengerEndFloorNumberAt(const int index) const 239 | { 240 | return this->passengerList.at(index).getEndFloorNumber(); 241 | } 242 | 243 | //****************************************************************************** 244 | // Function : getPassengerExitElevatorTimeAt 245 | // Process : Retrieves the exit elevator time of the specified passenger 246 | // Notes : None 247 | // 248 | // Revision History: 249 | // 250 | // Date Author Description 251 | // 7.23.11 Donne Martin Added function 252 | //****************************************************************************** 253 | inline int PassengerList::getPassengerExitElevatorTimeAt(const int index) const 254 | { 255 | return this->passengerList.at(index).getExitElevatorTime(); 256 | } 257 | 258 | //****************************************************************************** 259 | // Function : getPassengerIdAt 260 | // Process : Retrieves the id of the specified passenger 261 | // Notes : None 262 | // 263 | // Revision History: 264 | // 265 | // Date Author Description 266 | // 7.23.11 Donne Martin Added function 267 | //****************************************************************************** 268 | inline int PassengerList::getPassengerIdAt(const int index) const 269 | { 270 | return this->passengerList.at(index).getId(); 271 | } 272 | 273 | //****************************************************************************** 274 | // Function : getPassengerListSize 275 | // Process : Retrieves the passenger list size 276 | // Notes : None 277 | // 278 | // Revision History: 279 | // 280 | // Date Author Description 281 | // 7.23.11 Donne Martin Added function 282 | //****************************************************************************** 283 | inline int PassengerList::getPassengerListSize() const 284 | { 285 | return this->passengerList.size(); 286 | } 287 | 288 | //****************************************************************************** 289 | // Function : getPassengerStartFloorNumberAt 290 | // Process : Retrieves the start floor number of the specified passenger 291 | // Notes : None 292 | // 293 | // Revision History: 294 | // 295 | // Date Author Description 296 | // 7.23.11 Donne Martin Added function 297 | //****************************************************************************** 298 | inline int PassengerList::getPassengerStartFloorNumberAt(const int index) const 299 | { 300 | return this->passengerList.at(index).getStartFloorNumber(); 301 | } 302 | 303 | //****************************************************************************** 304 | // Function : getPassengerStartTimeAt 305 | // Process : Retrieves the start time of the specified passenger 306 | // Notes : None 307 | // 308 | // Revision History: 309 | // 310 | // Date Author Description 311 | // 7.23.11 Donne Martin Added function 312 | //****************************************************************************** 313 | inline int PassengerList::getPassengerStartTimeAt(const int index) const 314 | { 315 | return this->passengerList.at(index).getStartTime(); 316 | } 317 | 318 | //****************************************************************************** 319 | // Function : getPassengerStatusAt 320 | // Process : Retrieves the status of the specified passenger 321 | // Notes : None 322 | // 323 | // Revision History: 324 | // 325 | // Date Author Description 326 | // 7.23.11 Donne Martin Added function 327 | //****************************************************************************** 328 | inline Passenger::Status PassengerList::getPassengerStatusAt(const int index) const 329 | { 330 | return this->passengerList.at(index).getStatus(); 331 | } 332 | 333 | //****************************************************************************** 334 | // Function : setPassengerStatusAt 335 | // Process : Sets the status of the specified passenger 336 | // Notes : None 337 | // 338 | // Revision History: 339 | // 340 | // Date Author Description 341 | // 7.23.11 Donne Martin Added function 342 | //****************************************************************************** 343 | inline void PassengerList::setPassengerStatusAt(const int index, Passenger::Status status, const int time) 344 | { 345 | this->passengerList.at(index).setStatus(status, time); 346 | } 347 | 348 | #endif // PassengerList_h 349 | -------------------------------------------------------------------------------- /src/Elevator.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // 3 | // File Name: Elevator.h 4 | // 5 | // File Overview: Represents a Elevator 6 | // 7 | //****************************************************************************** 8 | // 9 | // Revision History: 10 | // 11 | // Date Author Description 12 | // 7.23.11 Donne Martin Added class 13 | //****************************************************************************** 14 | 15 | #ifndef Elevator_h 16 | #define Elevator_h 17 | 18 | #include 19 | #include "Passenger.h" 20 | #include "PassengerList.h" 21 | #include "SimulationTime.h" 22 | 23 | using namespace std; 24 | 25 | //****************************************************************************** 26 | // 27 | // Class: Elevator 28 | // 29 | // Revision History: 30 | // 31 | // Date Author Description 32 | // 7.23.11 Donne Martin Added class 33 | // 34 | // Notes: None 35 | // 36 | //****************************************************************************** 37 | class Elevator 38 | { 39 | public: 40 | 41 | //*************************************************************************** 42 | // Function : constructor 43 | // Description : None 44 | // Constraints : None 45 | //*************************************************************************** 46 | Elevator(); 47 | 48 | //*************************************************************************** 49 | // Function : destructor 50 | // Description : None 51 | // Constraints : None 52 | //*************************************************************************** 53 | virtual ~Elevator(); 54 | 55 | // Member functions in alphabetical order 56 | 57 | enum MoveState; // Oddly, seems to be required by Visual Studio 58 | // to avoid compile errors 59 | 60 | //*************************************************************************** 61 | // Function : addPassengerAtIndex 62 | // Description : Adds the specified passenger to our list 63 | // Constraints : None 64 | //*************************************************************************** 65 | void addPassengerAtIndex(const int index); 66 | 67 | //*************************************************************************** 68 | // Function : checkDropOffPassengers 69 | // Description : Checks if there are any passengers to drop off 70 | // Constraints : None 71 | //*************************************************************************** 72 | void checkDropOffPassengers(const bool movedUp); 73 | 74 | //*************************************************************************** 75 | // Function : checkForNewDestinationPassenger 76 | // Description : Checks for our new destination passenger 77 | // Constraints : None 78 | //*************************************************************************** 79 | void checkForNewDestinationPassenger(); 80 | 81 | //*************************************************************************** 82 | // Function : checkPickupPassengers 83 | // Description : Checks if there are any passengers to pick up 84 | // Constraints : None 85 | //*************************************************************************** 86 | void checkPickupPassengers(const bool movedUp); 87 | 88 | //*************************************************************************** 89 | // Function : determineNextDestinationPassenger 90 | // Description : Determines which passenger should be our dest passenger 91 | // Called after our dest passenger has been unloaded 92 | // Constraints : None 93 | //*************************************************************************** 94 | void determineNextDestinationPassenger(); 95 | 96 | //*************************************************************************** 97 | // Function : determinePassengerIdWithMaxEndFloor 98 | // Description : Looks at our list of passengers to determine the next 99 | // destination passenger based on the one who has the 100 | // highest end floor since the elevator is going up 101 | // Constraints : Relies on determinePassengerIdWithMaxEndFloor 102 | // Relies on determinePassengerIdWithMinEndFloor 103 | //*************************************************************************** 104 | int determinePassengerIdWithMaxEndFloor() const; 105 | 106 | //*************************************************************************** 107 | // Function : determinePassengerIdWithMinEndFloor 108 | // Description : Looks at our list of passengers to determine the next 109 | // destination passenger based on the one who has the 110 | // lowest end floor since the elevator is going down 111 | // Constraints : None 112 | //*************************************************************************** 113 | int determinePassengerIdWithMinEndFloor() const; 114 | 115 | //*************************************************************************** 116 | // Function : dropOffPassengers 117 | // Description : Drops off passengers in dropOffList at the current floor 118 | // Constraints : None 119 | //*************************************************************************** 120 | void dropOffPassengers(); 121 | 122 | //*************************************************************************** 123 | // Function : doNextMove 124 | // Description : Performs the elevator's next move 125 | // Constraints : None 126 | //*************************************************************************** 127 | void doNextMove(); 128 | 129 | //*************************************************************************** 130 | // Function : getMatchingPassengerStatus 131 | // Description : Retrieves the matching passenger status based on 132 | // the elevator's current move state 133 | // Constraints : None 134 | //*************************************************************************** 135 | Passenger::Status getMatchingPassengerStatus(); 136 | 137 | //*************************************************************************** 138 | // Function : getName 139 | // Description : Access for name 140 | // Constraints : None 141 | //*************************************************************************** 142 | inline void getName(string& name) const; 143 | 144 | //*************************************************************************** 145 | // Function : getTime 146 | // Description : Accessor for time 147 | // Constraints : None 148 | //*************************************************************************** 149 | inline int getTime() const; 150 | 151 | //*************************************************************************** 152 | // Function : handleElevatorMove 153 | // Description : Handles the elevator movement up or down 154 | // Constraints : None 155 | //*************************************************************************** 156 | void handleElevatorMove(const bool movedUp); 157 | 158 | //*************************************************************************** 159 | // Function : handleStopped 160 | // Description : Handles the stopped elevator 161 | // Constraints : None 162 | //*************************************************************************** 163 | void handleStopped(); 164 | 165 | //*************************************************************************** 166 | // Function : handleStopping 167 | // Description : Handles the elevator that is going to stop 168 | // Constraints : None 169 | //*************************************************************************** 170 | void handleStopping(); 171 | 172 | //*************************************************************************** 173 | // Function : isDestPassengerOnBoard 174 | // Description : Determines if the destination passenger is on board 175 | // Constraints : None 176 | //*************************************************************************** 177 | bool isDestPassengerOnBoard() const; 178 | 179 | //*************************************************************************** 180 | // Function : moveDown 181 | // Description : Handles the elevator moving down 182 | // Constraints : None 183 | //*************************************************************************** 184 | void moveDown(const int numFloors); 185 | 186 | //*************************************************************************** 187 | // Function : moveTowardsDestinationPassengerFloor 188 | // Description : Moves towards the destination passenger's floor 189 | // Constraints : None 190 | //*************************************************************************** 191 | void moveTowardsDestinationPassengerFloor(); 192 | 193 | //*************************************************************************** 194 | // Function : moveUp 195 | // Description : Handles the elevator moving up 196 | // Constraints : None 197 | //*************************************************************************** 198 | void moveUp(const int numFloors); 199 | 200 | //*************************************************************************** 201 | // Function : pickUpPassengers 202 | // Description : Picks up passengers in pickUpList at the current floor 203 | // Constraints : None 204 | //*************************************************************************** 205 | void pickUpPassengers(); 206 | 207 | //*************************************************************************** 208 | // Function : printMoveState 209 | // Description : Prints the move state (string as opposed to int) to cout 210 | // Constraints : None 211 | //*************************************************************************** 212 | void printMoveState() const; 213 | 214 | //*************************************************************************** 215 | // Function : printPassengerAction 216 | // Description : Prints the passengeer action to cout 217 | // Constraints : None 218 | //*************************************************************************** 219 | void printPassengerAction(const string& action, const int index) const; 220 | 221 | //*************************************************************************** 222 | // Function : printPassengerIds 223 | // Description : Prints the list of passenger ids to cout 224 | // Constraints : None 225 | //*************************************************************************** 226 | void printPassengerIds() const; 227 | 228 | //*************************************************************************** 229 | // Function : removePassengerAtIndex 230 | // Description : Removes the specified passenger from the elevator 231 | // Constraints : None 232 | //*************************************************************************** 233 | void removePassengerAtIndex(const int index); 234 | 235 | //*************************************************************************** 236 | // Function : setDestPassengerIndex 237 | // Description : Mutator for destPassengerIndex 238 | // Constraints : None 239 | //*************************************************************************** 240 | inline void setDestPassengerIndex(const int index); 241 | 242 | //*************************************************************************** 243 | // Function : setMoveState 244 | // Description : Mutator for destPassengerIndex 245 | // Constraints : None 246 | //*************************************************************************** 247 | inline void setMoveState(const Elevator::MoveState moveState); 248 | 249 | //*************************************************************************** 250 | // Function : setMoveStateToStopping 251 | // Description : Sets the elevator move state to STOPPING_GOING_UP or _DOWN 252 | // Constraints : None 253 | //*************************************************************************** 254 | void setMoveStateToStopping(const bool movedUp); 255 | 256 | //*************************************************************************** 257 | // Function : setName 258 | // Description : Mutator for name 259 | // Constraints : None 260 | //*************************************************************************** 261 | inline void setName(const string& name); 262 | 263 | //*************************************************************************** 264 | // Function : setTimeToNextFloor 265 | // Description : Mutator for timeToNextFloor 266 | // Constraints : None 267 | //*************************************************************************** 268 | inline void setTimeToNextFloor(const int timeToNextFloor); 269 | 270 | //*************************************************************************** 271 | // public Class Attributes 272 | //*************************************************************************** 273 | 274 | // Elevator movement state 275 | enum MoveState 276 | { 277 | INVALID_MOVE_STATE = -1, 278 | STOPPED_NO_PASSENGERS, 279 | STOPPED_GOING_UP, 280 | STOPPED_GOING_DOWN, 281 | STOPPING_GOING_UP, 282 | STOPPING_GOING_DOWN, 283 | MOVING_UP, 284 | MOVING_DOWN 285 | }; 286 | 287 | static const int INVALID_VALUE = -1; // Invalid value 288 | static const int MAX_PASSENGERS = 8; // Number of passengers/elevator 289 | static const int SEC_STOP = 2; // Time from STOPPING TO STOPPED 290 | 291 | private: 292 | Floor currFloor; // Current floor the elevator was on 293 | Floor destFloor; // Destination floor 294 | int destPassengerIndex; // Destination passenger index 295 | vector dropOffList; // Vector of passengers to drop off 296 | int moveFloorTimer; // Timer to move between destination 297 | MoveState moveState; // Elevator move state 298 | string name; // Elevator name 299 | list passengerIds; // List of Passengers ids on the elevator 300 | PassengerList* passengerListPtr; // List of Passengers (singleton) 301 | vector pickUpList; // Vector of passengers to pick up 302 | SimulationTime* simulationTimePtr; // Simulation time (singleton) 303 | int stopTimer; // Current timer to stop 304 | int timeToNextFloor; // Time in seconds to move between floors 305 | 306 | }; // end class Elevator 307 | 308 | //****************************************************************************** 309 | // Function : getName 310 | // Process : Accessor for name 311 | // Notes : None 312 | // 313 | // Revision History: 314 | // 315 | // Date Author Description 316 | // 7.23.11 Donne Martin Added function 317 | //****************************************************************************** 318 | inline void Elevator::getName(string& name) const 319 | { 320 | name = this->name; 321 | } 322 | 323 | //****************************************************************************** 324 | // Function : getTime 325 | // Process : Accessor for time 326 | // Notes : None 327 | // 328 | // Revision History: 329 | // 330 | // Date Author Description 331 | // 7.23.11 Donne Martin Added function 332 | //****************************************************************************** 333 | inline int Elevator::getTime() const 334 | { 335 | return this->simulationTimePtr->getTime(); 336 | } 337 | 338 | //****************************************************************************** 339 | // Function : setDestPassengerIndex 340 | // Process : Mutator for destPassengerIndex 341 | // Notes : None 342 | // 343 | // Revision History: 344 | // 345 | // Date Author Description 346 | // 7.23.11 Donne Martin Added function 347 | //****************************************************************************** 348 | inline void Elevator::setDestPassengerIndex(const int index) 349 | { 350 | this->destPassengerIndex = index; 351 | } 352 | 353 | //****************************************************************************** 354 | // Function : setMoveState 355 | // Process : Mutator for moveState 356 | // Notes : None 357 | // 358 | // Revision History: 359 | // 360 | // Date Author Description 361 | // 7.23.11 Donne Martin Added function 362 | //****************************************************************************** 363 | inline void Elevator::setMoveState(const Elevator::MoveState moveState) 364 | { 365 | this->moveState = moveState; 366 | } 367 | 368 | //****************************************************************************** 369 | // Function : setName 370 | // Process : Mutator for name 371 | // Notes : None 372 | // 373 | // Revision History: 374 | // 375 | // Date Author Description 376 | // 7.23.11 Donne Martin Added function 377 | //****************************************************************************** 378 | inline void Elevator::setName(const string& name) 379 | { 380 | this->name = name; 381 | } 382 | 383 | //****************************************************************************** 384 | // Function : setTimeToNextFloor 385 | // Process : Mutator for timeToNextFloor 386 | // Notes : None 387 | // 388 | // Revision History: 389 | // 390 | // Date Author Description 391 | // 7.23.11 Donne Martin Added function 392 | //****************************************************************************** 393 | inline void Elevator::setTimeToNextFloor(const int timeToNextFloor) 394 | { 395 | this->timeToNextFloor = timeToNextFloor; 396 | } 397 | 398 | #endif // Elevator_h 399 | -------------------------------------------------------------------------------- /src/Passenger.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // 3 | // File Name: Passenger.h 4 | // 5 | // File Overview: Represents an elevator Passenger 6 | // 7 | //****************************************************************************** 8 | // 9 | // Revision History: 10 | // 11 | // Date Author Description 12 | // 7.23.11 Donne Martin Added class 13 | //****************************************************************************** 14 | 15 | #ifndef Passenger_h 16 | #define Passenger_h 17 | 18 | #include 19 | #include 20 | #include "Floor.h" 21 | 22 | using namespace std; 23 | 24 | //****************************************************************************** 25 | // 26 | // Class: Passenger 27 | // 28 | // Revision History: 29 | // 30 | // Date Author Description 31 | // 7.23.11 Donne Martin Added class 32 | // 33 | // Notes: None 34 | // 35 | //****************************************************************************** 36 | class Passenger 37 | { 38 | public: 39 | 40 | //*************************************************************************** 41 | // Function : constructor 42 | // Description : None 43 | // Constraints : None 44 | //*************************************************************************** 45 | Passenger(); 46 | 47 | //*************************************************************************** 48 | // Function : destructor 49 | // Description : None 50 | // Constraints : None 51 | //*************************************************************************** 52 | virtual ~Passenger(); 53 | 54 | enum Status; // Oddly, seems to be required by Visual Studio 55 | // to avoid compile errors 56 | 57 | // Member functions in alphabetical order 58 | inline int getBoardElevatorTime() const; 59 | 60 | //*************************************************************************** 61 | // Function : getEndFloor 62 | // Description : Accessor for 63 | // Constraints : None 64 | //*************************************************************************** 65 | inline void getEndFloor(Floor& endFloor) const; 66 | 67 | //*************************************************************************** 68 | // Function : getEndFloorNumber 69 | // Description : Accessor for 70 | // Constraints : None 71 | //*************************************************************************** 72 | inline int getEndFloorNumber() const; 73 | 74 | //*************************************************************************** 75 | // Function : getExitElevatorTime 76 | // Description : Accessor for 77 | // Constraints : None 78 | //*************************************************************************** 79 | inline int getExitElevatorTime() const; 80 | 81 | //*************************************************************************** 82 | // Function : getId 83 | // Description : Accessor for 84 | // Constraints : None 85 | //*************************************************************************** 86 | inline int getId() const; 87 | 88 | //*************************************************************************** 89 | // Function : getStartTime 90 | // Description : Accessor for 91 | // Constraints : None 92 | //*************************************************************************** 93 | inline int getStartTime() const; 94 | 95 | //*************************************************************************** 96 | // Function : getStartFloor 97 | // Description : Accessor for 98 | // Constraints : None 99 | //*************************************************************************** 100 | inline void getStartFloor(Floor& startFloor) const; 101 | 102 | //*************************************************************************** 103 | // Function : getStartFloorNumber 104 | // Description : Accessor for 105 | // Constraints : None 106 | //*************************************************************************** 107 | inline int getStartFloorNumber() const; 108 | 109 | //*************************************************************************** 110 | // Function : getStatus 111 | // Description : Accessor for 112 | // Constraints : None 113 | //*************************************************************************** 114 | inline Passenger::Status getStatus() const; 115 | 116 | //*************************************************************************** 117 | // Function : printStatus 118 | // Description : Prints the status in text (opposed to int) 119 | // Constraints : None 120 | //*************************************************************************** 121 | void printStatus() const; 122 | 123 | //*************************************************************************** 124 | // Function : resetBoardTime 125 | // Description : Resets boardElevatorTime to INIT_TO_INVALID 126 | // Constraints : None 127 | //*************************************************************************** 128 | inline void resetBoardTime(); 129 | 130 | //*************************************************************************** 131 | // Function : resetExitTime 132 | // Description : Resets exitElevatorTime to INIT_TO_INVALID 133 | // Constraints : None 134 | //*************************************************************************** 135 | inline void resetExitTime(); 136 | 137 | //*************************************************************************** 138 | // Function : resetStatus 139 | // Description : Resets status to NOT_SET 140 | // Constraints : None 141 | //*************************************************************************** 142 | inline void resetStatus(); 143 | 144 | //*************************************************************************** 145 | // Function : setEndFloor 146 | // Description : Mutator for endFloor 147 | // Constraints : None 148 | //*************************************************************************** 149 | inline void setEndFloor(const Floor& endFloor); 150 | 151 | //*************************************************************************** 152 | // Function : setId 153 | // Description : Mutator for id 154 | // Constraints : None 155 | //*************************************************************************** 156 | inline void setId(const int id); 157 | 158 | //*************************************************************************** 159 | // Function : setStartFloor 160 | // Description : Mutator for startFloor 161 | // Constraints : None 162 | //*************************************************************************** 163 | inline void setStartFloor(const Floor& startFloor); 164 | 165 | //*************************************************************************** 166 | // Function : setStartTime 167 | // Description : Mutator for startTime 168 | // Constraints : None 169 | //*************************************************************************** 170 | inline void setStartTime(const int startTime); 171 | 172 | //*************************************************************************** 173 | // Function : setStatus 174 | // Description : Mutator for status 175 | // Updates passenger boardElevatorTime and exitElevatorTime 176 | // Constraints : None 177 | //*************************************************************************** 178 | void setStatus(const Passenger::Status status, int time); 179 | 180 | //*************************************************************************** 181 | // public Class Attributes 182 | //*************************************************************************** 183 | 184 | // Determines passenger status 185 | enum Status 186 | { 187 | NOT_SET = -1, 188 | QUEUED_WAITING_FLAGGED, 189 | QUEUED_WAITING_UP, 190 | QUEUED_WAITING_DOWN, 191 | RIDING, 192 | COMPLETED 193 | }; 194 | 195 | static const int INIT_TO_INVALID = -1; // Invalid value 196 | 197 | private: 198 | 199 | //*************************************************************************** 200 | // Function : setBoardElevatorTime 201 | // Description : Mutator for boardElevatorTime 202 | // Constraints : Private, call setStatus instead 203 | //*************************************************************************** 204 | inline void setBoardElevatorTime(const int boardElevatorTime); 205 | 206 | //*************************************************************************** 207 | // Function : setExitElevatorTime 208 | // Description : Mutator for exitElevatorTime 209 | // Constraints : Private, call setStatus instead 210 | //*************************************************************************** 211 | inline void setExitElevatorTime(const int exitElevatorTime); 212 | 213 | int id; // Passenger id 214 | int startTime; // Start time in seconds 215 | Floor startFloor; // Start floor 216 | Floor endFloor; // End floor 217 | Status status; // Passenger status 218 | int boardElevatorTime; // Used to calculate wait time 219 | // until picked up by elevator 220 | int exitElevatorTime; // Used to calculate travel time on the elevator 221 | 222 | }; // end class Passenger 223 | 224 | //****************************************************************************** 225 | // Function : getBoardElevatorTime 226 | // Process : Accessor for boardElevatorTime 227 | // Notes : None 228 | // 229 | // Revision History: 230 | // 231 | // Date Author Description 232 | // 7.23.11 Donne Martin Added function 233 | //****************************************************************************** 234 | inline int Passenger::getBoardElevatorTime() const 235 | { 236 | return this->boardElevatorTime; 237 | } 238 | 239 | //****************************************************************************** 240 | // Function : getEndFloor 241 | // Process : Accessor for endFloor 242 | // Notes : None 243 | // 244 | // Revision History: 245 | // 246 | // Date Author Description 247 | // 7.23.11 Donne Martin Added function 248 | //****************************************************************************** 249 | inline void Passenger::getEndFloor(Floor& endFloor) const 250 | { 251 | endFloor = this->endFloor; 252 | } 253 | 254 | //****************************************************************************** 255 | // Function : getEndFloorNumber 256 | // Process : Accessor for endFloor's number 257 | // Notes : None 258 | // 259 | // Revision History: 260 | // 261 | // Date Author Description 262 | // 7.23.11 Donne Martin Added function 263 | //****************************************************************************** 264 | inline int Passenger::getEndFloorNumber() const 265 | { 266 | return this->endFloor.getNumber(); 267 | } 268 | 269 | //****************************************************************************** 270 | // Function : getExitElevatorTime 271 | // Process : Accessor for exitElevatorTime 272 | // Notes : None 273 | // 274 | // Revision History: 275 | // 276 | // Date Author Description 277 | // 7.23.11 Donne Martin Added function 278 | //****************************************************************************** 279 | inline int Passenger::getExitElevatorTime() const 280 | { 281 | return this->exitElevatorTime; 282 | } 283 | 284 | //****************************************************************************** 285 | // Function : getId 286 | // Process : Accessor for id 287 | // Notes : None 288 | // 289 | // Revision History: 290 | // 291 | // Date Author Description 292 | // 7.23.11 Donne Martin Added function 293 | //****************************************************************************** 294 | inline int Passenger::getId() const 295 | { 296 | return this->id; 297 | } 298 | 299 | //****************************************************************************** 300 | // Function : getStartTime 301 | // Process : Accessor for startTime 302 | // Notes : None 303 | // 304 | // Revision History: 305 | // 306 | // Date Author Description 307 | // 7.23.11 Donne Martin Added function 308 | //****************************************************************************** 309 | inline int Passenger::getStartTime() const 310 | { 311 | return this->startTime; 312 | } 313 | 314 | //****************************************************************************** 315 | // Function : getStartFloor 316 | // Process : Accessor for startFloor 317 | // Notes : None 318 | // 319 | // Revision History: 320 | // 321 | // Date Author Description 322 | // 7.23.11 Donne Martin Added function 323 | //****************************************************************************** 324 | inline void Passenger::getStartFloor(Floor& startFloor) const 325 | { 326 | startFloor = this->startFloor; 327 | } 328 | 329 | //****************************************************************************** 330 | // Function : getStartFloorNumber 331 | // Process : Accessor for startFloor's number 332 | // Notes : None 333 | // 334 | // Revision History: 335 | // 336 | // Date Author Description 337 | // 7.23.11 Donne Martin Added function 338 | //****************************************************************************** 339 | inline int Passenger::getStartFloorNumber() const 340 | { 341 | return this->startFloor.getNumber(); 342 | } 343 | 344 | //****************************************************************************** 345 | // Function : getStatus 346 | // Process : Accessor for status 347 | // Notes : None 348 | // 349 | // Revision History: 350 | // 351 | // Date Author Description 352 | // 7.23.11 Donne Martin Added function 353 | //****************************************************************************** 354 | inline Passenger::Status Passenger::getStatus() const 355 | { 356 | return this->status; 357 | } 358 | 359 | //****************************************************************************** 360 | // Function : resetBoardTime 361 | // Process : Resets boardElevatorTime to INIT_TO_INVALID 362 | // Notes : None 363 | // 364 | // Revision History: 365 | // 366 | // Date Author Description 367 | // 7.23.11 Donne Martin Added function 368 | //****************************************************************************** 369 | inline void Passenger::resetBoardTime() 370 | { 371 | this->boardElevatorTime = Passenger::INIT_TO_INVALID; 372 | } 373 | 374 | //****************************************************************************** 375 | // Function : resetExitTime 376 | // Process : Resets exitElevatorTime to INIT_TO_INVALID 377 | // Notes : None 378 | // 379 | // Revision History: 380 | // 381 | // Date Author Description 382 | // 7.23.11 Donne Martin Added function 383 | //****************************************************************************** 384 | inline void Passenger::resetExitTime() 385 | { 386 | this->exitElevatorTime = Passenger::INIT_TO_INVALID; 387 | } 388 | 389 | //****************************************************************************** 390 | // Function : resetStatus 391 | // Process : Resets the status to NOT_SET 392 | // Notes : None 393 | // 394 | // Revision History: 395 | // 396 | // Date Author Description 397 | // 7.23.11 Donne Martin Added function 398 | //****************************************************************************** 399 | inline void Passenger::resetStatus() 400 | { 401 | this->status = Passenger::NOT_SET; 402 | } 403 | 404 | //****************************************************************************** 405 | // Function : setEndFloor 406 | // Process : Mutator for endFloor 407 | // Notes : None 408 | // 409 | // Revision History: 410 | // 411 | // Date Author Description 412 | // 7.23.11 Donne Martin Added function 413 | //****************************************************************************** 414 | inline void Passenger::setEndFloor(const Floor& endFloor) 415 | { 416 | this->endFloor = endFloor; 417 | } 418 | 419 | //****************************************************************************** 420 | // Function : setBoardElevatorTime 421 | // Process : Mutator for boardElevatorTime 422 | // Notes : None 423 | // 424 | // Revision History: 425 | // 426 | // Date Author Description 427 | // 7.23.11 Donne Martin Added function 428 | //****************************************************************************** 429 | inline void Passenger::setBoardElevatorTime(const int boardElevatorTime) 430 | { 431 | this->boardElevatorTime = boardElevatorTime; 432 | } 433 | 434 | //****************************************************************************** 435 | // Function : setExitElevatorTime 436 | // Process : Mutator for exitElevatorTime 437 | // Notes : None 438 | // 439 | // Revision History: 440 | // 441 | // Date Author Description 442 | // 7.23.11 Donne Martin Added function 443 | //****************************************************************************** 444 | inline void Passenger::setExitElevatorTime(const int exitElevatorTime) 445 | { 446 | this->exitElevatorTime = exitElevatorTime; 447 | } 448 | 449 | //****************************************************************************** 450 | // Function : setId 451 | // Process : Mutator for id 452 | // Notes : None 453 | // 454 | // Revision History: 455 | // 456 | // Date Author Description 457 | // 7.23.11 Donne Martin Added function 458 | //****************************************************************************** 459 | inline void Passenger::setId(const int id) 460 | { 461 | this->id = id; 462 | } 463 | 464 | //****************************************************************************** 465 | // Function : setStartFloor 466 | // Process : Mutator for start floor 467 | // Notes : None 468 | // 469 | // Revision History: 470 | // 471 | // Date Author Description 472 | // 7.23.11 Donne Martin Added function 473 | //****************************************************************************** 474 | inline void Passenger::setStartFloor(const Floor& startFloor) 475 | { 476 | this->startFloor = startFloor; 477 | } 478 | 479 | //****************************************************************************** 480 | // Function : setStartTime 481 | // Process : Mutator for start time 482 | // Notes : None 483 | // 484 | // Revision History: 485 | // 486 | // Date Author Description 487 | // 7.23.11 Donne Martin Added function 488 | //****************************************************************************** 489 | inline void Passenger::setStartTime(const int startTime) 490 | { 491 | this->startTime = startTime; 492 | } 493 | 494 | #endif // Passenger_h 495 | --------------------------------------------------------------------------------