X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=position.hpp;h=029966d75e979a9a64b29b74b559f53001ee2691;hb=2172ce055533d5865d58538ee00bf609e59b0f99;hp=76fa6b6d390ba514b9a2e8d0b55fcdabc1b5e609;hpb=90cabce172856326923f36c9a05fae01138d25aa;p=cs356-p1-elevator.git diff --git a/position.hpp b/position.hpp index 76fa6b6..029966d 100644 --- a/position.hpp +++ b/position.hpp @@ -7,69 +7,31 @@ #ifndef POSITION_HPP #define POSITION_HPP +#include + 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); - protected: + 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; + + private: - int _major; - int _minor; + int major_; + int minor_; }; #endif /* POSITION_HPP */