Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program 1A Triangle and Circle Classes You will implement 2 classes named Triangle and Circle. All names will be exactly as specified here, case included.
Program 1A Triangle and Circle Classes You will implement 2 classes named Triangle and Circle. All names will be exactly as specified here, case included. You will submit a .cpp file and a .h file for each of these classes. The submission is 4 files total. You will write your own test driver to exercise and test these classes but you will not submit the test driver to me. I will have my own test driver and will plug your classes into my project to test them. - General note - Make sure all the integers receive positive values. If a negative value is given, handle it gracefully. Suggestions include convert it to a positive value of the same magnitude (change 1 to 1 ), or provide a default value and issue an error message. See note about the Triangle::GetArea() function - make sure this doesn't crash and do error checking as described. - The Triangle class will contain the following private data: integer side 1 integer side 2 integer side3 - The triangle classes will contain 2 constructors and one destructor. The destructor in this case will simply display a parting message (Ex: "Good bye cruel world! You won't have the Triangle to kick around anymore!") The constructors will be: A default constructor with no arguments. It will provide default values to the member variables Another constructor will take 3 integers as arguments and will set the member variables to those values. - The Triangle class will contain the following public functions: Function name Return type Argument(s) Description GetSide1() integer None Returns the integer member variable side1 SetSide1() void integer Sets the member variable side1 to the integer argument passed GetSide2() integer None Returns the integer member variable side2 SetSide2() void integer Sets the member variable side2 to the integer argument passed GetSide3() integer None Returns the integer member variable side3 SetSide3() void integer Sets the member variable side3 to the integer argument passed GetArea() float None Calculates the area of the triangle from the member data of the length of the sides of the triangle. If the values for the sides produce invalid results, return 0 and output a meaningful error statement. GetPerimeter() integer None Calculates the perimeter length of the triangle from the member data of the length of the sides of the triangle - The Circle class will contain the following private data: integer radius string fillColor string borderColor Constant float PI, assigned the value of PI to 5 decimal places The Circle class will contain 2 constructors and one destructor. The destructor in this case will simply display a parting message (Ex: "Help me, I'm melting!") The constructors will be: A default constructor with no arguments. It will provide default values to the member variables Another constructor will take 1 integer and 2 strings as arguments and will set the member variables to those values. - The Circle class will contain the following public functions: Function name Return type Argument(s) Description GetRadius() integer None Returns the integer member variable radius SetRadius() void integer Sets the member variable radius to the integer argument passed GetFillColor() string none Returns the member variable fillColor SetFillColor() void string Sets the member variable fillColor to the string argument given. GetBorderColor() string none Returns the member variable borderColor SetBorderColor() void string Sets the member variable fillColor to the string argument given. GetArea() float None Calculates the area of the from the member data of the radius of the circle. GetPerimeter() integer Non Calculates the perimeter length of the triangle from the member data of the length of the sides of the triangle - If the Circle class needs any functions to do its work internally, they will be private. Program 1A Triangle and Circle Classes You will implement 2 classes named Triangle and Circle. All names will be exactly as specified here, case included. You will submit a .cpp file and a .h file for each of these classes. The submission is 4 files total. You will write your own test driver to exercise and test these classes but you will not submit the test driver to me. I will have my own test driver and will plug your classes into my project to test them. - General note - Make sure all the integers receive positive values. If a negative value is given, handle it gracefully. Suggestions include convert it to a positive value of the same magnitude (change 1 to 1 ), or provide a default value and issue an error message. See note about the Triangle::GetArea() function - make sure this doesn't crash and do error checking as described. - The Triangle class will contain the following private data: integer side 1 integer side 2 integer side3 - The triangle classes will contain 2 constructors and one destructor. The destructor in this case will simply display a parting message (Ex: "Good bye cruel world! You won't have the Triangle to kick around anymore!") The constructors will be: A default constructor with no arguments. It will provide default values to the member variables Another constructor will take 3 integers as arguments and will set the member variables to those values. - The Triangle class will contain the following public functions: Function name Return type Argument(s) Description GetSide1() integer None Returns the integer member variable side1 SetSide1() void integer Sets the member variable side1 to the integer argument passed GetSide2() integer None Returns the integer member variable side2 SetSide2() void integer Sets the member variable side2 to the integer argument passed GetSide3() integer None Returns the integer member variable side3 SetSide3() void integer Sets the member variable side3 to the integer argument passed GetArea() float None Calculates the area of the triangle from the member data of the length of the sides of the triangle. If the values for the sides produce invalid results, return 0 and output a meaningful error statement. GetPerimeter() integer None Calculates the perimeter length of the triangle from the member data of the length of the sides of the triangle - The Circle class will contain the following private data: integer radius string fillColor string borderColor Constant float PI, assigned the value of PI to 5 decimal places The Circle class will contain 2 constructors and one destructor. The destructor in this case will simply display a parting message (Ex: "Help me, I'm melting!") The constructors will be: A default constructor with no arguments. It will provide default values to the member variables Another constructor will take 1 integer and 2 strings as arguments and will set the member variables to those values. - The Circle class will contain the following public functions: Function name Return type Argument(s) Description GetRadius() integer None Returns the integer member variable radius SetRadius() void integer Sets the member variable radius to the integer argument passed GetFillColor() string none Returns the member variable fillColor SetFillColor() void string Sets the member variable fillColor to the string argument given. GetBorderColor() string none Returns the member variable borderColor SetBorderColor() void string Sets the member variable fillColor to the string argument given. GetArea() float None Calculates the area of the from the member data of the radius of the circle. GetPerimeter() integer Non Calculates the perimeter length of the triangle from the member data of the length of the sides of the triangle - If the Circle class needs any functions to do its work internally, they will be private
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