Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE HELP!! in C++ make a Rectangle.cpp file that implements with the Rectangle.h file in thenimage below. a. Constructor and destructor: The constructor takes four

PLEASE HELP!!
in C++ make a Rectangle.cpp file that implements with the Rectangle.h file in thenimage below.
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.
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
Point.h file 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 & getPoint(); Point & getPointc(); 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 */ Point.h #ifndef Point_h #define Point_h class Point{ friend std::ostream & operator

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions