Advertisement
bojandam1

Untitled

May 23rd, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class Circle{
  5. private:
  6. double radius;
  7. string color;
  8. public:
  9. Circle()
  10. {
  11. radius=1.0;
  12. color="red";
  13. }
  14. Circle(double r,string c)
  15. {
  16. radius=r;
  17. color=c;
  18. }
  19. double getRadius(){
  20. return radius;
  21. }
  22. void setRadis(double rad){
  23. radius=rad;
  24. }
  25. string getColor()
  26. {
  27. return color;
  28. }
  29. void setColor(string col)
  30. {
  31. color=col;
  32. }
  33. double getArea()
  34. {
  35. return 3.14159*radius*radius;
  36. }
  37.  
  38.  
  39. };
  40.  
  41. int main()
  42. {
  43. Circle krug;
  44. krug.setRadis(1.2);
  45. cout<<"Radius="<<krug.getRadius()<<" Area="<<krug.getArea()<<" Color="<<krug.getColor()<<endl;
  46. Circle krug1(2.1,"blue");
  47. cout<<"Radius="<<krug1.getRadius()<<" Area="<<krug1.getArea()<<" Color="<<krug1.getColor()<<endl;
  48. Circle krug2;
  49. cout<<"Radius="<<krug2.getRadius()<<" Area="<<krug2.getArea()<<" Color="<<krug2.getColor()<<endl;
  50. return 0;
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement