Question: 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

 Can someone check my code pls? required functions Program requirements and/or

constraints: Add two constructors, default constructor and the constructor with 3 parameters

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

handling the 3 sides. Your functions should call the private functions largest

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!