Question: ` ` ` Rectanglelmp.cpp > { } Rectanglelmp 1 namespace RectangleImp { / / Rectangle class Rectangle { public: / / Declare public methods here
Rectanglelmp.cpp Rectanglelmp
namespace RectangleImp
Rectangle
class Rectangle
public:
Declare public methods here
private:
Create length and width here
;
void Rectangle::setLengthdouble len
Write setLength here
void Rectangle::setwidthdouble wid
write setWidth here
double Rectangle::getLength
write getLength here
double Rectangle::getWidth
write getWidth here
double Rectangle::calculateArea
write calculateArea here
double Rectangle::calculatePerimeter
write calculatePerimeter here
@ MyRectangleClassProgram.cpp main
This program uses the programmerdefined Rectangle class.
#include "RectangleImp.cpp
#include
using namespace std;
using namespace RectangleImp;
int main
Create Rectangle objects here
Set the lengths and widths here
Print the areas and perimeters here
return ;
Your Tasks
In this lab, you create a programmerdefined class and then use it in a C program. The program should create two Rectangle objects and find their area and perimeter. Use the Circle class that you worked with in Exercise as a guide.
Instructions
Open the class file RectangleImp.cpp
In the Rectangle class, create two private attributes named length and width. Both length and width should be data type double.
Task : Write public set and get methods to set and get the values for length.
Task : Write public set and get methods to set and get the values for width.
Task : Write a public calculateArea method and a public calculatePerimeter method to calculate and return the area of the rectangle and the perimeter of the rectangle.
Open the MyRectangleClassProgram.cpp create two Rectangle objects named rectangle and rectangle using the default constructor as you saw in MyEmployeeClassProgram.cpp
Set the length of rectangle to mathbf and the width to mathbf Set the length of rectangle to mathbf and the width to mathbf Print the value of rectangles perimeter and area, and then print the value of rectangles perimeter and area. An example of the program is shown below:
Perimeter of rectangle is
Area of rectangle is
Perimeter of rectangle is
Area of rectangle is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
