620a6e1169e967d8d3dd1c1b8ab6f6ec11fb242a
[cs356-p1-elevator.git] / stop.cpp
1 #include "stop.hpp"
2
3 Stop::Stop (const Position& position, const Direction& direction)
4         : position_(position)
5         , direction_(direction)
6 {
7         // Intentionally Left Empty
8 }
9
10 bool Stop::operator== (const Stop& rhs) const
11 {
12         if (rhs.position_ != position_)
13                 return false;
14
15         if (direction_ == ALL || rhs.direction_ == ALL)
16                 return true;
17
18         return (rhs.direction_ == direction_);
19 }
20
21 bool Stop::operator< (const Stop& rhs) const
22 {
23         /* If we do not use the direction to help differentiate, then it is
24          * possible that an object can be neither less, greater, or equal */
25         return ((position_ < rhs.position_) || (direction_ < rhs.direction_));
26 }
27
28 bool Stop::operator> (const Stop& rhs) const
29 {
30         return (position_ > rhs.position_);
31 }
32
33 const Direction Stop::getDirection () const
34 {
35         return direction_;
36 }
37
38 std::ostream& operator<< (std::ostream& os, const Stop& rhs)
39 {
40         os << "Stop(" << rhs.position_ << ", " << rhs.direction_ << ")";
41         return os;
42 }
43
44
45 /* vim: set ts=4 sts=4 sw=4 noexpandtab textwidth=112: */