Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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 above

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

Step: 3

blur-text-image

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago

Question

Discuss the various types of policies ?

Answered: 1 week ago

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago

Question

Explain the need for and importance of co-ordination?

Answered: 1 week ago