Answered step by step
Verified Expert Solution
Link Copied!

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

Step 2: Create a program to do the following

  • Create 2 Triangle objects using the constructor
  • Create a User Menu with the following options
    1. Update the data in Triangle Object 1 and output the resulting area and perimeter
    2. Update the data in Triangle Object 2 and output the resulting area and perimeter
    3. Increment one of the 2 Triangle objects
    4. Add the 2 objects and output the result
    5. Subtract the 2 objects and output the result
    6. Determine if the first triangle object is greater than the second

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_2

Step: 3

blur-text-image_3

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

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago

Question

=+country competitive advantages? Why? Support your point of view.

Answered: 1 week ago

Question

=+from: a) a MNEs perspective? and b) the HRM managers perspective?

Answered: 1 week ago