Question: //Please follow the instructions and solve it by C++ Rectangle.h - A complete Rectangle Class including both declaration and definition appRectangle,cpp (do not named as

//Please follow the instructions and solve it by C++

Rectangle.h - A complete Rectangle Class including both declaration and definition

appRectangle,cpp (do not named as main.cpp)

To Repeat the Program 13-4 Rectangle Class exercise in the Gaddis Textbook (version 1 @ p.732 on 8th ed, or p.742 on 9th ed ) where the class definition and implementation are separated into a different file.

Submit: Rectangle.h, appRectangle,cpp, and test run screenshot.

Test Run

Submit

  • class header file: Rectangle.h (or combined with application .cpp)
  • test application file: testRectangle,cpp
  • Validation test run result

// The source file of the Program 13-4

// This program uses smart pointers to allocate three

// instances of the Rectangle class.

#include

#include

using namespace std;

// Rectangle class declaration.

class Rectangle

{

private:

double width;

double length;

public:

void setWidth(double);

void setLength(double);

double getWidth() const;

double getLength() const;

double getArea() const;

};

//**************************************************

// setWidth assigns a value to the width member. *

//**************************************************

void Rectangle::setWidth(double w)

{

width = w;

}

//**************************************************

// setLength assigns a value to the length member. *

//**************************************************

void Rectangle::setLength(double len)

{

length = len;

}

//**************************************************

// getWidth returns the value in the width member. *

//**************************************************

double Rectangle::getWidth() const

{

return width;

}

//****************************************************

// getLength returns the value in the length member. *

//****************************************************

double Rectangle::getLength() const

{

return length;

}

//*****************************************************

// getArea returns the product of width times length. *

//*****************************************************

double Rectangle::getArea() const

{

return width * length;

}

//*****************************************************

// Function main *

//*****************************************************

int main()

{

double number; // To hold a number

double totalArea; // The total area

// Dynamically allocate the objects.

unique_ptr kitchen(new Rectangle);

unique_ptr bedroom(new Rectangle);

unique_ptr den(new Rectangle);

// Get the kitchen dimensions.

cout

cin >> number; // Get the length

kitchen->setLength(number); // Store in kitchen object

cout

cin >> number; // Get the width

kitchen->setWidth(number); // Store in kitchen object

// Get the bedroom dimensions.

cout

cin >> number; // Get the length

bedroom->setLength(number); // Store in bedroom object

cout

cin >> number; // Get the width

bedroom->setWidth(number); // Store in bedroom object

// Get the den dimensions.

cout

cin >> number; // Get the length

den->setLength(number); // Store in den object

cout

cin >> number; // Get the width

den->setWidth(number); // Store in den object

// Calculate the total area of the three rooms.

totalArea = kitchen->getArea() + bedroom->getArea() +

den->getArea();

// Display the total area of the three rooms.

cout

return 0;

}

- 0 x CA\Users\tony\Downloads\v\Week01\appRectangle.exe This program will calculate the area of a rectangle. What is the width? 3 What is the length? 4 Here is the rectangle's data: Width: 3 Length: 4 Area: 12 Process returned o (@x0) Press any key to continue. execution time : 4.500 s

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!