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.
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