//------------------------------- // File : Point.H // Author : DL Frey // Date : 2/21/03 // Section: 1234 // SSN : xxx-xx-1234 // Project: CMSC 202 Spring 2003, Project 2 // Description: // This file is the interface for a generic // Point class encapsulating the X- and Y- coordinates // of a Point. It was developed for project 2, // but can be reused in any project // defines x- and y-coordinates as integers, // but no implementation depends on it //------------------------------------------- #ifndef POINT_H #define POINT_H class Point { public: // ------------------------------------ // Method: Constructor(s) // PreConditions: none // PostConditions: // x- and y- coordinates set to values // passed in as params //------------------------------------- Point ( int x = 0, int y = 0); // ------------------------------------------ // Method: SetX() - mutator for x-coordinate // PreConditions: none // PostConditions: // changes the value of the x-coordinate to // value supplied by the user //------------------------------------- void SetX (int x); // ------------------------------------------ // Method: GetX() - accessor for x-coordinate // PreConditions: none // PostConditions: // returns integer value of x-coordinate //------------------------------------- int GetX ( void ) const; // ------------------------------------------ // Method: SetY() - mutator for y-coordinate // PreConditions: none // PostConditions: // changes the value of the y-coordinate to // value supplied by the user //------------------------------------- void SetY (int y); // ------------------------------------------ // Method: GetY() - accessor for y-coordinate // PreConditions: none // PostConditions: // returns integer value of y-coordinate //------------------------------------- int GetY ( void ) const; private: int m_XCoordinate; int m_YCoordinate; }; //--------------------------------------------- // generic distance calculations for two points // in the coordinate plane //--------------------------------------------- // ------------------------------------------------ // Function: VerticalDistance // PreConditions: none // PostConditions: // returns the absolute value of the difference // of the y-coordinates of the user supplied Points //------------------------------------------------- int VerticalDistance (const Point& point1, const Point& point2); // ------------------------------------------------ // Function: HorizontalDistance // PreConditions: none // PostConditions: // returns the absolute value of the difference // of the x-coordinates of the user supplied Points //------------------------------------------------- int HorizontalDistance (const Point& point1, const Point& point2); // ------------------------------------------------ // Function: Distance // PreConditions: none // PostConditions: // returns the straight-line distance between // the user supplied Points //------------------------------------------------- double Distance (const Point& point1, const Point& point2); #endif