Solved–Homework # 3– Solution

$30.00 $19.00

In this homework, you will write your first C++ class. Your class name will be Triangle. This class can represent a triangle on a 2D plane with sides of length A, B, C such as T =(A=3.0, B=4.0, C=5.0) Your class will have the following features A no parameter constructor (A, B, C are all…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

Rate this product

In this homework, you will write your first C++ class. Your class name will be Triangle. This class can represent a triangle on a 2D plane with sides of length A, B, C such as T =(A=3.0, B=4.0, C=5.0)

Your class will have the following features

  • A no parameter constructor (A, B, C are all 1.0)

  • A one parameter constructor that will set all triangle sides to the given value.

  • A two parameter constructor that will set A and B sides and set the C side to 1.0

  • A three parameter constructor

  • Setter and getters for the required data members.

  • Input and Output functions for the triangle sides.

  • Three functions that return the angle of a triangle corner (angleA, angleB, angleC)

  • A function that returns true if the triangle is a right angle triangle

  • A function that returns the area of the triangle

  • A function that returns the perimeter of the triangle

You will apply all object oriented rules we learned during the lectures (member initializer syntax, const keywords, etc.)

Test each function of your new class at least two times with different parameters. You should also write two functions that will take Triangle objects using call by value and call by reference.

Notes:

  • Do not use any functions from the standard C library (like printf)

  • Do not forget to indent your code and provide comments.

  • You should always check if the triangle is valid, if not then print out an error message (cerr) and exit the program