Question: Q: Hello, I want you to explain me this code in step by step and if possible use commed for explaining blow: Question was: Make
Q: Hello, I want you to explain me this code in step by step and if possible use commed for explaining blow:
Question was:
Make class composition out of 3 classes:
1.Class Computer, that contains of fields: at least 2 computer parameters by your choice, price. Implement methods:
Constructor SetComputer (Assigns fields values)
PrintComputer
GetField (for each field)
2.Class Monitor, that contains of fields: at least 2 monitor parameters by your choice, price. Implement methods:
Constructor SetMonitor (Assigns fields values)
PrintMonitor
GetLauks (for each field)
3.Class Complect, that contains of fields : name, computer, monitor. Implement methods:
Constructor SetComplect (Assigns fields values)
GetName
GetPrice (Calculates the total price)
PrintComplect (including price)
CODE:
#include
//creating Triangle class class Triangle{ public: double a,b,c; //set method to check whether triangle exist or not bool Set(double aa,double bb,double cc){ a=aa; b=bb; c=cc; cout<<"The triangle which such edge exist or not : "; //sum of any two sides should be greater than third side if( ((aa+bb>cc) && (aa+cc>bb)) && (bb+cc>aa) ){ return true; }else{ return false; } } //method to find the perimeter double Perim(){ cout<<"The perimeter of the triangle is : "; double p=(a+b+c); return p; } //method to find the area double Area(){ cout<<"The Area of the triangle is : "; //calculating the area double s=(a+b+c)/double(2); double area=sqrt(s*(s-a)*(s-b)*(s-c)); return area; } //method to check if the triangle is right angled bool IsRect(){ cout<<"The triangle is right-angled or not : "; a=a*a; b=b*b; c=c*c; //sum of squares of any two sides should to be equal square of third side if(a==b+c||b==a+c||c==a+b){ return true; }else{ return false; } } };
//driver program int main() { Triangle t; //creating object of the class double a,b,c; cout<<"Enter the three sides of a triangle"<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
