Experimental Changes
[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 <vector>
12 #include "position.hpp"
13 #include "direction.hpp"
14 #include "stop.hpp"
15
16
17 enum door_status { CLOSED, OPEN };
18 const float elevator_step = 0.1;
19
20 class bad_direction { };
21
22 class Elevator
23 {
24         public:
25                 /*
26                  * PURPOSE: Construct a new Elevator object
27                  *
28                  * REQUIRE: Nothing
29                  *
30                  * PROMISE: A new Elevator will be constructed
31                  */
32                 Elevator ();
33
34                 /*
35                  * PURPOSE: Tell the elevator to stop at the given floor,
36                  * PURPOSE: going in the given direction.
37                  *
38                  * REQUIRE: floor is a valid floor
39                  * REQUIRE: direction is either UP or DOWN
40                  *
41                  * PROMISE: The elevator will stop at the floor when it gets there
42                  */
43                 void stop_at (int floor, enum direction _direction);
44
45                 /*
46                  * PURPOSE: The elevator will move 1/10th of a floor in the current
47                  * PURPOSE: direction.
48                  *
49                  * REQUIRE: Nothing
50                  *
51                  * PROMISE: The elevator will move if it has floors to stop at, otherwise
52                  * PROMISE: it will sit idle at its current place.
53                  */
54                 void move ();
55
56         protected:
57                 /*
58                  * PURPOSE: Find the direction we should move in
59                  *
60                  * REQUIRE: _direction must be IDLE
61                  *
62                  * PROMISE: The best direction to move will be returned
63                  */
64                 enum direction find_best_direction ();
65
66                 /*
67                  * PURPOSE: Figure out if we are currently at a Stop in _stops
68                  *
69                  * REQUIRE: Nothing
70                  *
71                  * PROMISE: Return true if we are at a Stop in _stops, false otherwise
72                  */
73                 bool currently_at_stop ();
74
75         private:
76                 /* Storage for all of the places that we will be stopping */
77                 std::vector<Stop> _stops;
78
79                 /* Storage for the current elevator position */
80                 Position _pos;
81
82                 /* Stores the current direction */
83                 enum direction _direction;
84
85                 /* Stores the current door status */
86                 enum door_status _door_status;
87
88 };
89
90 #endif /* ELEVATOR_HPP */
91
92 /* vim: set ts=4 sts=4 sw=4 noexpandtab textwidth=112: */