Lab 7 Â Â - Rectangleclass-Â Â (Lec. 7)
1.) Create a new project and
name it:Â Â Â Rectangle
/* OUTPUT: Enter the width of the court: 60 Enter the length of the court: 120 The width of the court is 60 feet. The length of the court is 120 feet. The area of the court is 7200 square feet. Press any key to continue . . . */ |
|
2.) Create the following 3 files:
- Rectangle.h
- Rectangle.cpp
- Source.cpp
3.) Write a program that produces
this output:
Rectangle.h
4.)In the Rectangle.h file, write a class specificationfor a Rectangle class.
           2 private data members:     _width (int)and _length (int)
           7 public member functions:
     Defaultconstructor - Assigns ‘safe’ values to the data members.
     Descructor
     setWidth – An int value, passed from main(), is assignedto _width.
     setLength - An int value, passed from main(), is assignedto _length.
     getWidth – Returns the object’s width.
     getLength – Returns the object’s length.
     getArea– Calculates the area of the Rectangle object and returns thevalue.
Rectangle.cpp
5.) In the Rectangle.cpp file, write a functionimplementation for each function
prototype listed in the Rectangle class specification.
Source.cpp
6.)In main(), declare an object of Rectangletype, andname it:Â Â Â tennisCourt
7.) In main(), declare three variables ofdouble data type, and
               and name them:  width,length and area
6.) Prompt the user to enter a width and length (seeoutput).
7.) Read in the user’s inputs and assign them to the datamembers of tennisCourt,
            by using the ‘set’ member functions.
8.)Then assign the tennis court’s width,length and area to variable inmain() by
            using the ‘get’ member functions.
9.)Display the width, length, and area. (see output)