// NAME CSCI 201 Assignment 5 DATE #include #include "Rectangle.h" Rectangle :: Rectangle(double xc, double yc, double w, double h){ SetX_center(xc); SetY_center(yc); SetWidth(w); SetHeight(h); } // Function definitions for inspectors. double Rectangle :: GetWidth() const { return width; } double Rectangle :: GetHeight() const { return height; } double Rectangle :: GetX_center() const { return x_center; } double Rectangle :: GetY_center() const { return y_center; } // Function definitions for mutators void Rectangle :: SetWidth(double w){ // make sure that the rectangle will fit on the monitor screen if (w > 0 && w < 120) width = w; else width = 1; } void Rectangle :: SetHeight(double h){ // make sure that the rectangle will fit on the monitor screen if (h > 0 && h < 40) height = h; else height = 1; } void Rectangle :: SetX_center(double xc){ // make sure that the rectangle will fit on the monitor screen if ( xc > 0 && (xc + width / 2.0 < 120) ) x_center = xc; else x_center = 1; } void Rectangle :: SetY_center(double yc){ // make sure that the rectangle will fit on the monitor screen if ( yc > 0 && (yc + height / 2.0 < 40) ) y_center = yc; else y_center = 1; } // Function definitions for facilitators double Rectangle :: Area() const { return (width * height); } double Rectangle :: Perimeter() const { return (2.0 * (width + height)); } void Rectangle :: Display() const { cout << endl; for (int i = 1; i <= height; i++) { cout << " "; for (int j = 1; j <= width; j++) { cout << '*'; } cout << endl; } }