d78ecd864028cdbb8e1f0f12618b1e69c61a8978
[cs356-p1-elevator.git] / elevator.hpp
1 /*
2  * CS356 Project 01 -- Elevator Simulator
3  *
4  * Elevator Class Specification
5  */
6
7 #ifndef ELEVATOR_HPP
8 #define ELEVATOR_HPP
9
10 #include <iostream>
11 //#include <set>
12 #include <vector>
13 #include "position.hpp"
14 #include "direction.hpp"
15 #include "stop.hpp"
16
17
18 enum door_status { CLOSED, OPEN };
19 const int elevator_step = 0.1;
20
21 class bad_direction { };
22
23 class Elevator
24 {
25         public:
26                 /*
27                  * PURPOSE: Construct a new Elevator object
28                  *
29                  * REQUIRE: Nothing
30                  *
31                  * PROMISE: A new Elevator will be constructed
32                  */
33                 Elevator ();
34
35                 /*
36                  * PURPOSE: Tell the elevator to stop at the given floor,
37                  * PURPOSE: going in the given direction.
38                  *
39                  * REQUIRE: floor is a valid floor
40                  * REQUIRE: direction is a valid direction
41                  *
42                  * PROMISE: The elevator will stop at the floor when it gets there
43                  */
44                 void stop_at (int floor, enum direction _direction);
45
46                 /*
47                  * PURPOSE: The elevator will move 1/10th of a floor in the current
48                  * PURPOSE: direction.
49                  *
50                  * REQUIRE: Nothing
51                  *
52                  * PROMISE: The elevator will move if it has floors to stop at, otherwise
53                  * PROMISE: it will sit idle at its current place.
54                  */
55                 void move ();
56
57         protected:
58                 /*
59                  * PURPOSE: Find the direction we should move in
60                  *
61                  * REQUIRE: _direction must be IDLE
62                  *
63                  * PROMISE: The best direction to move will be returned
64                  */
65                 enum direction find_best_direction ();
66
67         private:
68                 /* Storage for all of the places that we will be stopping */
69                 //std::set<Stop> _stops;
70                 std::vector<Stop> _stops;
71
72                 /* Storage for the current elevator position */
73                 Position _pos;
74
75                 /* Stores the current direction */
76                 enum direction _direction;
77
78                 /* Stores the current door status */
79                 enum door_status _door_status;
80
81 };
82
83 #endif /* ELEVATOR_HPP */
84
85 /* vim: set ts=4 sts=4 sw=4 noexpandtab textwidth=112: */