Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone check my code pls? required functions Program requirements and/or constraints: Add two constructors, default constructor and the constructor with 3 parameters handling the

Can someone check my code pls?

required functions

image text in transcribed

image text in transcribed

Program requirements and/or constraints: Add two constructors, default constructor and the constructor with 3 parameters handling the 3 sides. Your functions should call the private functions largest and smallest where is appropriate Your main function (Assignment6.cpp) will do the following: Construct a Triangle object by asking user for the 3 sides and then checking to see if the user Triangle is right triangle, equilateral, isosceles, or/and scalene. It will ask the user if they want to check another triangle and if the user types y it will repeat the process if the user input is n then it will exit the program.

here is my code can you check the errors? ( i know alot of erros)

/ File triangle.cpp -- Rectangle class function implementation file

#include "triangle.h"

//*******************************************************************

// triangle::setLength *

// If the argument passed to the setLength function is zero or *

// greater, it is copied into the member variable length and true *

// is returned. If the argument is negative, the value of length *

// remains unchanged and false is returned. *

//*******************************************************************

bool triangle::setBase(double bas)

{

bool validData = true;

if (len >= 0)

base = bas; // Copy argument to length

else

validData = false; // Leave length unchanged

return validData;

}

//*******************************************************************

// triangle::setWidth *

// If the argument passed to the setWidth function is zero or *

// greater, it is copied into the member variable width and true *

// is returned. If the argument is negative, the value of width *

// remains unchanged and false is returned. *

//*******************************************************************

bool triangle::setHieght(double h)

{

bool validData = true;

if (w >= 0)

hieght = h; // Copy argument to width

else

validData = false; // Leave width unchanged

return validData;

}

//********************************************************************

// Triangle::getLength *

// getLength returns the value in the private member variable length.*

//********************************************************************

double triangle::getbase()

{

return base;

}

//********************************************************************

// Triangle::getWidth *

// getWidth returns the value in the private member variable width. *

//********************************************************************

double triangle::getHeight()

{

return hieght;

}

//********************************************************************

// Triangle::getArea *

// getArea calculates and returns the area of the rectangle. *

//********************************************************************

double triangle::getArea()

{

return (base * hieght)/2 ;

}

----------------------------------------------------------------------

// This is a program that uses the Rectangle class. // The Rectangle class declaration is in the Rectangle.h file. // The Rectangle class function definitions are in the Rectangle.cpp // file. These files should all be combined into a project.

#include #include "triangle.h" // Contains Rectangle class declaration using namespace std;

int main() { triangle shape; // Declare a Rectangle object string shapesIsosceles , shapeRight, shapeEquilateral, shapeScalene;

//Get box length and width cout > boxLength; cout > boxWidth;

// Call member functions to set triangle dimensions if (!box.setLength(boxLength)) // Store the length cout

--------------------------------------------------------------------------

/ File triangle.h -- Rectangle class specification file #ifndef triangle.h #define triangle.h

// triangle class declaration class trinagle { private: double length; double width; public: bool setLength(double); bool setWidth(double); double getLength(); double getWidth(); double getArea(); }; #endif

------------------------------------------------------------

This is the outcome of the code

image text in transcribed

Function Name Triangle () Triangle (int sl, int s2, int s3) Constructor. Sets up a triangle with the specified Description of the Method Default Triangle, sets the three sides to zero side lengths. private int largest Returns the length of the longest side of the triangle. This is a helper method. private int smallest() Returns the length of the shortest side of the triangle. This is a helper method

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

Sidestep common tone and grammar problems

Answered: 1 week ago

Question

=+What kinds of problems need to be overcome?

Answered: 1 week ago

Question

=+Describe an important trade-off you recently faced

Answered: 1 week ago