Advertisement
stirante

cpp

Sep 14th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. //SEGMENT
  2. #include "segment.h"
  3.  
  4. Segment::Segment()
  5. {
  6.  
  7. }
  8.  
  9. //TROJKAT
  10. #include "trojkat.h"
  11.  
  12. #include<math.h>
  13.  
  14. Trojkat::Trojkat(double a, double b)
  15. {
  16.     this->a = a;
  17.     this->b = b;
  18. }
  19.  
  20. double Trojkat::pole()
  21. {
  22.     return (a * b) / 2;
  23. }
  24.  
  25. double Trojkat::obwod()
  26. {
  27.     return a + b + (sqrt((a * a) + (b * b)));
  28. }
  29.  
  30. std::string Trojkat::typ()
  31. {
  32.     return "Trojkat prostokatny";
  33. }
  34.  
  35.  
  36. //KWADRAT
  37. #include "kwadrat.h"
  38.  
  39. Kwadrat::Kwadrat(double a)
  40. {
  41.     this->a = a;
  42. }
  43.  
  44. double Kwadrat::pole()
  45. {
  46.     return a * a;
  47. }
  48.  
  49. double Kwadrat::obwod()
  50. {
  51.     return 4 * a;
  52. }
  53.  
  54. std::string Kwadrat::typ()
  55. {
  56.     return "Kwadrat";
  57. }
  58.  
  59.  
  60. //PROSTOKAT
  61. #include "prostokat.h"
  62.  
  63. Prostokat::Prostokat(double a, double b)
  64. {
  65.     this->a = a;
  66.     this->b = b;
  67. }
  68.  
  69. double Prostokat::pole()
  70. {
  71.     return a * b;
  72. }
  73.  
  74. double Prostokat::obwod()
  75. {
  76.     return 2 * a + 2 * b;
  77. }
  78.  
  79. std::string Prostokat::typ()
  80. {
  81.     return "Prostokat";
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement