Question: Please write a c++ program using the attached templates (CPP and h file) to create a Triangle class that does the task below. Templates are

Please write a c++ program using the attached templates (CPP and h file) to create a Triangle class that does the task below. Templates are for circle but should adapt for Triangle. Please include the triangle.h header file and the triangle main.cpp file in your reply answer.

Tasks

1. create .cpp and .h files

2. propose some methods, including computeArea(). isTriangle(), computeCircumference(), setTriangle(), getSide1(). getSide2(),.....

3. submission must include .cpp, .h, and .xls files

CPP Source Template for TRIANGLE

#include #include "Circle.h"

using namespace std; using namespace std;

int main(){ // object initilization or create a new object from the class Circle //circle1 is an object name //You HAVE TO CREATE OBJECTS BEFORE USING THEM Circle circle0;

//use the object cout << circle0.computeArea()<

Circle circle1(1.0); //use the object cout << circle1.computeArea()<< endl; cout << circle1.computeCircumference()<< endl;

Circle circle2(2.0); //use the object cout << circle2.computeArea()<< endl; cout << circle2.computeCircumference()<< endl;

//test your method cin.get(); }

Template Example for Header.h file (header should be for Triangle not Circle)

const double PI=3.14;

class Circle{ private: //properties double radius; //int color;

public: //default construct Circle(); Circle(double radius); ~Circle();

//accessor void setRadius(double myRadius); double getRadius();

//methods double computeArea(); double computeCircumference();

//create an other method using the radius };

Circle::Circle(){ radius=1.0; }

Circle::Circle(double myRadius){ radius=myRadius; }

Circle::~Circle(){ // }

double Circle::computeArea(){ return PI*pow(radius,2); }

double Circle::computeCircumference(){ return 2*PI*radius; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!