Answered step by step
Verified Expert Solution
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.
Point.h file
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started