Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me on C++ using code blocks Define the class rectangleType with data

ID: 652405 • Letter: P

Question

Please help me on C++ using code blocks

Define the class rectangleType with data members: length and width of type double. Include the following public member functions:
? setDimension(double l, double w); getLength(); getWidth(); area(); perimeter(); print();
? setLength(double l); to set the length and a reference to the object (the address of the object) is returned.
? setWidth(double w); to set the width and returns the resulting object..
? operator+(); to add the dimensions of 2 rectangles and to return a reference to the resulting object.
? operator++(); to post-increment the dimensions of 2 rectangles and to return a reference to the resulting object.
? Operator==(); to return the result of equating 2 rectangles.
? Operator!=(); to return the negation of operator==().
? Operator>(); to return the result of comparing 2 rectangles for greater than relationship.
? Operator<(); to return the result of comparing 2 rectangles smaller than relationship.
? Constructor with the 2 default parameters set to 0 and have the same names as the data members (i.e. : length and width).

1.Study the testDriver and sample output results above and then explain the difference between Line#1 and Line#2.
2. Study the testDriver and sample output results, then explain why the last results for r1 and r4 are similar.

testProg.cpp

//Test Program: class rectangleType

#include
#include
#include "rectangleType.h"

using namespace std;

int main()
{
rectangleType r1, r2;
rectangleType r3(3, 6), r4(6, 4), r5, r6;

cout << fixed << showpoint << setprecision(2);

r1.setLength(15).setWidth(12.00); //Line #1

cout << "r1: ";
r1.print();

r2.setWidth(5.00).setLength(9.00); //Line #2

cout << "r2: ";
r2.print();

r5 = r1 + r2;
r6 = (r3++)++;

cout << " r5 (adding 2 rects (r1 & r2)): ";
r5.print();

cout << " r6 (post-incrementing r3) : ";
r6.print();

r1.setLength(3).setWidth(3);
r2.setLength(4).setWidth(4);
r3.setLength(5).setWidth(5);

r4 = r1 + r2 +r3; //Line#3

cout << " r1 (adding 3 rects): ";
r1.print();
cout << "r4 (adding 3 rects): ";
r4.print();
cout << "r2 (adding 3 rects): ";
r2.print();
cout << "r3 (adding 3 rects): ";
r3.print();

cout<<" Comparison of r2 && r3... ";
if (r2 == r3)
cout<<"r2 & r3 are equal";
else if (r2 > r3)
cout<<"r2 > r3";
else
cout<<"r2 < r3";

r2++;
cout<<" Comparison of r2 && r3 after r2++... ";
if (r2 == r3)
cout<<"r2 & r3 are equal";
else if (r2 > r3)
cout<<"r2 > r3";
else
cout<<"r2 < r3";

return 0;
}

"C:Users 100641Documents My Coursesa12111Spring 14_15 Labslab8inDebug his2.exe" 2: Length = 0.00 ; width = 5.00; Area= 0. 00: Perinet er 10.00 r5 (adding 2 rects (rl & r2)): 17.00; Area= 255.00; Perimeter 64.00 ength -- 15.00; width = 6 (post-incrementing r3) Length = 5.00; width = 8.00; Area= 40.00; Perimeter= 26.00 1 (adding 3 rects): Length = 4 (adding 3 rects): Length = 2 (adding 3 rects): Length = 3 (adding 3 rects): Length = 12.00; width = 12.00; width = 4.00; width = 5.00; width = 144.00; Perimeter 12.00; Area = 12.00; Area = 4.00: Area = 5.00; Area= 144.00; Perimeter = 16.00: Perimeter = 25.00; Perimeter= 48.00 48.00 16.00 20.00 omparison of r2 && r3. .. omparison of r2 && r3 after r2++. . . 2 & r3 are equal Process returned 0 (0x0) execution time : 0.289:s ress any key to continue

Explanation / Answer

class Rectangle

{

public:

double length, width;

public:

void setDimensions(double a,double b)

{

length = a;

width = b;

}

void area()

{

double area = length*width;

}

void perimeter()

{

permeter = 2*(length + breadth);

}

void print()

{

cout<<"length:"<<length<<"width:"<<width<<"area:"<<area<<"Perimeter:"<<perimeter<<endl;

}

Rectangle void operator +(Rectangle r1,r2)// implementing operator overloading

{

Rectangle r3;

r3.length = r1.length + r2.length;

return r3;

}

Rectangle void operator ++(Rectangle r1)// implementing operator overloading

{

Rectangle r4;

r4.length = r1.length + 1;

r4.width = r1.width + 1;

return r4;

}

}

public void main()

{

Rectangle r1, r2, result1, result;

r1.getDimensions(5,7);

r2.getDimensions(7,9);

result1 = r1 + r2;

result1.area();

result1.perimeter();

result1.print();

result = r1++;

result.area();

result.perimeter();

result.print();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote