X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=position.hpp;h=029966d75e979a9a64b29b74b559f53001ee2691;hb=2172ce055533d5865d58538ee00bf609e59b0f99;hp=02f4feb62a3dc9f13a7e1397dbc992fee8d9a0a1;hpb=dd9988b5db6dc820c5fcd07f88513d126e926d22;p=cs356-p1-elevator.git diff --git a/position.hpp b/position.hpp index 02f4feb..029966d 100644 --- a/position.hpp +++ b/position.hpp @@ -11,73 +11,27 @@ class Position { + friend std::ostream& operator<< (std::ostream& os, const Position& rhs); + public: - /* - * PURPOSE: Construct a new Position object - * - * REQUIRE: Nothing - * - * PROMISE: A new Position object will be created, that - * PROMISE: starts at position 0. - */ Position (); - - /* - * PURPOSE: Construct a new Position object - * - * REQUIRE: Nothing - * - * PROMISE: A new Position object will be created, and will - * PROMISE: start at position initial_position - */ Position (int initial_position); - /* - * PURPOSE: Compare two position objects - * - * REQUIRE: rhs is a valid Position object - * - * PROMISE: True if rhs is at the same position, false otherwise - */ - bool operator== (const Position& rhs); - - /* - * PURPOSE: Compare a Position and a float - * - * REQUIRE: Nothing - * - * PROMISE: True if rhs is within 0.05 of this Position - */ - bool operator== (const int rhs); - - /* - * PURPOSE: Add to this Position - * - * REQUIRE: Nothing - * - * PROMISE: This Position will have the rhs added to it - */ Position& operator+= (const float rhs); - - /* - * PURPOSE: Subtract from this Position - * - * REQUIRE: Nothing - * - * PROMISE: This Position will have the rhs added to it - */ Position& operator-= (const float rhs); - bool operator< (const Position& rhs); - bool operator> (const Position& rhs); - - friend std::ostream& operator<< (std::ostream& os, Position& rhs); + bool operator== (const Position& rhs) const; + bool operator!= (const Position& rhs) const; + bool operator< (const Position& rhs) const; + bool operator> (const Position& rhs) const; + Position operator- (const Position& rhs) const; + operator float() const; + operator int() const; - protected: - int _major; - int _minor; private: + int major_; + int minor_; }; #endif /* POSITION_HPP */