//------------------------------------------- // Filename : Quadrilateral.H // Author : DL Frey // Date : 2/20/03 // Project : CMSC 202 Spring 2003 Project 2 // Section : 1234 // SSN : xxx-xx-1234 // // This file provides the interface for // the Quadrilateral class required for project 2 // The Quadrilateral uses Point objects to store // x- and y-coordinates of it's corners // // Per the project specification, the implementation // of this class assumes // 1. the base (LL to LR) is parallel to the x-axis // 2. for trapezoids, the parallel sides are also // paralled to one of the axes //--------------------------------------------- #ifndef QUADRILATERAL_H #define QUADRILATERAL_H #include "Point.H" using namespace std; class Quadrilateral { public: // -------------------------------- // Method: Default constructor // PreConditions: none // PostConditions: // A new quadrilateral is created with // all corners constructed per Point's // default constructor Quadrilateral( void ); // mutators for the corners //----------------------------------- // Method: SetUpperLeft // PreConditions: none // PostConditions: UpperLeft corner set to p //----------------------------------- void SetUpperLeft (const Point& p); //----------------------------------- // Method: SetUpperRight // PreConditions: none // PostConditions: UpperRight corner set to p //----------------------------------- void SetUpperRight (const Point& p); //----------------------------------- // Method: SetLowerLeft // PreConditions: none // PostConditions: LowerLeft corner set to p //----------------------------------- void SetLowerLeft (const Point& p); //----------------------------------- // Method: SetLowerRight // PreConditions: none // PostConditions: LowerRight corner set to p //----------------------------------- void SetLowerRight (const Point& p); // accessors for corners //------------------------------------------ // Method: GetUpperLeft // PreConditions: none // PostConditions: UpperLeft corner returned //------------------------------------------ const Point& GetUpperLeft ( void ) const; //------------------------------------------ // Method: GetUpperRight // PreConditions: none // PostConditions: UpperRight corner returned //------------------------------------------ const Point& GetUpperRight ( void ) const; //------------------------------------------ // Method: GetLowerLeft // PreConditions: none // PostConditions: LowerLeft corner returned //------------------------------------------ const Point& GetLowerLeft ( void ) const; //------------------------------------------ // Method: GetLowerRight // PreConditions: none // PostConditions: LowerRight corner returned //------------------------------------------ const Point& GetLowerRight ( void ) const; // Quadrilateral Categorization Methods //-------------------------------- // Method: IsParallelogram // PreConditions: none // PostConditions: // returns true if both pairs of sides // are equal in length //--------------------------------- bool IsParallelogram( void ) const; //-------------------------------- // Method: IsRectangle // PreConditions: none // PostConditions: // returns true if the Quadrilateral // is a prallelogram with one right angle // (which implies it has 4 right angles) //--------------------------------- bool IsRectangle( void ) const; //--------------------------------------- // Method: IsSquare // PreConditions: none // PostConditions: // returns true if the Quadrilateral // is a rectangle with equal length sides //---------------------------------------- bool IsSquare (void ) const; //--------------------------------------- // Method: IsTrapezoid // PreConditions: none // PostConditions: // returns true if the Quadrilateral // has exactly one pair of parallel sides //---------------------------------------- bool IsTrapezoid (void) const; //--------------------------------------- // Method: IsIrregular // PreConditions: none // PostConditions: // returns true if the Quadrilateral // is none of the above //---------------------------------------- bool IsIrregular (void) const; //--------------------------------------- // Method: Area // PreConditions: none // PostConditions: // calculates and returns the area of // the quadrilateral. Per project 2 specifications // the area of an irregular quadrilateral is // returned as 0.0 //---------------------------------------- double Area( void ) const; //--------------------------------------- // Method: Area // PreConditions: none // PostConditions: // calculates and returns the area of // the quadrilateral //---------------------------------------- double Perimeter (void ) const; private: Point m_upperLeft; Point m_upperRight; Point m_lowerLeft; Point m_lowerRight; double TrapezoidArea (void ) const; }; #endif