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;
- protected:
- int _major;
- int _minor;
private:
+ int major_;
+ int minor_;
};
#endif /* POSITION_HPP */