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

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago