Answered step by step
Verified Expert Solution
Question
1 Approved Answer
USE C++ Step 1: Create a Triangle class. Create your Triangle class header and implementation files and the main program file Include 2 data members
USE C++
Step 1: Create a Triangle class. Create your Triangle class header and implementation files and the main program file
- Include 2 data members
- base, height
- Include the following methods
- Constructor that accepts the base and height as arguments
- Create a member function to set the base
- Create a member function to set the height
- Calculate Area (calculate base x height)
- Calculate perimeter
- Overload the Addition operator (+) as a non member function
- The overloaded + operator should separately add the base data members and the height data members
- Overload the Subtraction operator (-) as a member function
- The overloaded - operator should separately subtract the base data members and the height data members
- The - operator should set the value to zero for either data member if the calculation results in a negative
- Overload the equivalence operator (==) as a non member function
- Equivalence should be defined as the area of the two objects being equal
- Overload the greater than operator (>) as a member function
- Greater than should be defined as the area of one object being greater than the other
- Overload the increment operator (++) as a member function
- Overload the increment operator as a postfix operator
- The overloaded ++ operator should increment the base and height data members by 1
- The overloaded - operator should separately subtract the base data members and the height data members
Step 2: Create a program to do the following
- Create 2 Triangle objects using the constructor
- Create a User Menu with the following options
- Update the data in Triangle Object 1 and output the resulting area and perimeter
- Update the data in Triangle Object 2 and output the resulting area and perimeter
- Increment one of the 2 Triangle objects
- Add the 2 objects and output the result
- Subtract the 2 objects and output the result
- Determine if the first triangle object is greater than the second
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