Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with this question please! I have included the relevant header dile Rectangle.h in the image below. WILL UPVOTE! Need to Implement Rectangle.cpp a.

Need help with this question please! I have included the relevant header dile Rectangle.h in the image below. WILL UPVOTE!
Need to Implement Rectangle.cpp
a. Constructor and destructor: The constructor takes four Point objects as
parameters and calls setAll() function to set them. It also displays a message
that a specific points constructor is being called.
Destructor displays a similar
message. Conform to the output formats given in the sample output below.
b. Setters and getters: implement setAll() to set all the points at once. This
function calls formRectangle(). If it returns false setAll throws an
invalid_argument exception. Otherwise it sets the data members to the
parameter values. Getters return the data member values.
c. formRectangle(): This function checks whether the given coordinates of the
points form a rectangle and returns true or false based on the resulting
calculations. The following rule must hold for four points to be a rectangle:
Given points a, b, c, d for a rectangle, opposite sides and diagonals of a
rectangle must be of equal length.
You may use the following formula to calculate the length of a side between
two points:
Length of a side between points a and b = !|a. x b. x|( + |a. y b. y|(
You may use fabs() function to get the absolute value, sqrt() function to get
the square root and pow() function to calculate exponentiation. While fabs()
and sqrt() functions accept only one argument, pow() function accepts two
arguments: base and exponent. They are all part of the cmath standard library.
Add the following to your code to use this library:
#include
d. calculateArea(): This function returns the area of the rectangle. To calculate
area, you must first calculate the length of sides of the rectangle.
e. calculatePerimeter(): This function returns the perimeter of the rectangle. To
be able to calculate that you must again calculate sides of the rectangle.
image text in transcribed
Rectangle.h #ifndef Rectangle_h #define Rectangle_h #include "Point.h" class Rectangle { public: Rectangle(Point &, Point &, Point &, Point &); Rectangle(); void setAll(Point &, Point &, Point &, Point &); Point & getPoint(); Point & getPointB(); Point & getPoint(); Point & getPointD(); double calculateArea() const; double calculatePerimenter() const; private: Point pointA; Point pointB; Point pointc; Point pointD; bool formRectangle(Point &, Point &, Point &, Point &); }; #endif /* Rectangle_h */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions