Question: Implement a Polygon class and write a main driver program to allow for the instantiation of mutliple polygon objects each of varying length and width.
Implement a Polygon class and write a main driver program to allow for the instantiation of mutliple polygon objects each of varying length and width.
The definition of the Polygon class should be in an individual header (.h) file and the implementation of the class's methods should be in an individual source (.cpp) file.
The class should be designed around the following characteristics:
The name of the class should be Polygon.
The class should be composed of at least the following (data) members:
MAX_POLYGONS, (static constant) data member to indicate the maximum possible objects that can be instantiated for this class. The assigned value should be 25.
numPolygons, (static) data member to indicate the number of polygons physically instantiated.
length, data member to represent the length of the polygon.
width, data member to represent the width of the polygon.
perimeter, this value will be calculated based on the values of length and width.
area, this value will be calculated based on the values of length and width.
MIN, (constant) data member that represents the minimum possible value for the length and width of a specific polygon object. Unless otherwise specified, this value should be set to DEFAULT_MIN.
MAX, (constant) data member that represents the maximum possible value for the length and width of a specific polygon object. Unless otherwise specified, this value should be set to DEFAULT_MAX.
DEFAULT_MIN, (static constant) represents the default value to initialize the MIN data member of each object when a specific minimum value is not passed. The value assigned should be 10.
DEFAULT_MAX, (static constant) represents the default value to initialize the MAX data member of each object when a specific maximum value is not passed. The value assigned should be 100..
The class should include at least the following methods:
Default Constructor, initializes each data member with appropriate default values.
Constructor, initializes the object with specific values for the MIN and MAX data members. Remaining data members should be initialized appropriately.
Constructor, initializes the object with specific values for length, width, MIN, and MAX. Remaining data members should be initialized appropriately.
Destructor, clears out all the data members and adjusts any class level data as needed.
A method to populate the data members {length, width} from external (user) input.
Mutator methods for each data member or logical groupings, as necessary. Note that these methods should ensure the integrity of the object and should not allow data to be saved that is not appropriate for that data member. Example, length and width must be between MIN and MAX inclusive.
A method to calculate the area of the polygon.
A method to calculate the perimeter of the polygon.
Note that these methods can be invoked implicitly when an object is constructed with specific values for length and width or explicitly by the application after the values for length and width have been set.
A method to display the pertinent data members {length, width, area, perimeter}.
A method to draw a polygon of the specified length and width. You can use any character to draw the shape (i.e. border) of the polygon.
The class should allow for the instantiation of constant objects. In other words applications which use this class should be able to create polygon objects of type const.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
