Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help with C++ In this lab, we will design a simple triangle class. Use the Rectangle class given in the book and lecture notes as
Help with C++
In this lab, we will design a simple triangle class. Use the Rectangle class given in the book and lecture notes as a starting point to build a class for triangles. Your class, Triangle, must meet the following requirements A default constructor that initializes all sides to 0.0 Variables to hold the three sides of a triangle (a, b, and c). All values should be doubles since this will give the most precision when computing the area of the triangle. Member functions to set all side variables and to check that the values entered are greater than zero. Make sure your setter functions return a Boolean value to indicate that the value was accepted (true) or not greater than zero (false). An example setter function prototype is shown below 1. 2. 3. bool setA (double) 4. Member functions to get all side variables. An example getter function prototype is shown below double getA A member function that returns the area of the triangle. Use Heron's formula to calculate the area of a triangle from the length of its three sides. The following link demonstrates the formula: 5. formula 6. A member function to print details about the triangle to the console Separate the triangle specification file (Triangle.h) and implementation (Triangle.cpp) in separate files Additionally, you must also write a third file (.cpp) that contains the non-member function main), that is responsible for testing your class. Your tests must demonstrate that your class successfully works and meets the criterion we have given you above. In this lab, we will design a simple triangle class. Use the Rectangle class given in the book and lecture notes as a starting point to build a class for triangles. Your class, Triangle, must meet the following requirements A default constructor that initializes all sides to 0.0 Variables to hold the three sides of a triangle (a, b, and c). All values should be doubles since this will give the most precision when computing the area of the triangle. Member functions to set all side variables and to check that the values entered are greater than zero. Make sure your setter functions return a Boolean value to indicate that the value was accepted (true) or not greater than zero (false). An example setter function prototype is shown below 1. 2. 3. bool setA (double) 4. Member functions to get all side variables. An example getter function prototype is shown below double getA A member function that returns the area of the triangle. Use Heron's formula to calculate the area of a triangle from the length of its three sides. The following link demonstrates the formula: 5. formula 6. A member function to print details about the triangle to the console Separate the triangle specification file (Triangle.h) and implementation (Triangle.cpp) in separate files Additionally, you must also write a third file (.cpp) that contains the non-member function main), that is responsible for testing your class. Your tests must demonstrate that your class successfully works and meets the criterion we have given you aboveStep 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