Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. class domino
  6. {
  7. private:
  8. int numer_lewy, numer_prawy;
  9. int dlugosc = 1;
  10. public:
  11. domino(int lewy = 0, int prawy = 6)
  12. {
  13. this->numer_lewy = lewy;
  14. this->numer_prawy = prawy;
  15.  
  16. }
  17.  
  18.  
  19. void display()
  20. {
  21. cout << "|" << this->numer_lewy << "( Dlugosc " << this->dlugosc << " )" << this->numer_prawy << "|" << endl;
  22. }
  23.  
  24. static domino add(domino& dodajaca, domino& nowa)
  25. {
  26.  
  27.  
  28.  
  29. dodajaca.dlugosc++;
  30.  
  31. if (dodajaca.mozna(nowa))
  32. {
  33. if (dodajaca.numer_lewy == nowa.numer_prawy)
  34. {
  35. dodajaca.numer_lewy = dodajaca.numer_prawy;
  36. dodajaca.numer_prawy = nowa.numer_lewy;
  37.  
  38. }
  39. else
  40. dodajaca.numer_prawy = nowa.numer_prawy;
  41. }
  42.  
  43. return dodajaca;
  44.  
  45. }
  46.  
  47. friend bool operator==(domino& bv1, domino& bv2);
  48.  
  49. bool mozna(domino& jeden)
  50. {
  51.  
  52. if (((this->numer_lewy == jeden.numer_lewy) || (this->numer_prawy == jeden.numer_prawy)) || (this->numer_prawy==jeden.numer_lewy) || (this->numer_lewy==jeden.numer_prawy))
  53. return true;
  54. else
  55. return false;
  56. }
  57. };
  58.  
  59. bool operator==(domino& bv1, domino& bv2)
  60. {
  61. if (((bv1.numer_lewy == bv2.numer_prawy) || (bv1.numer_lewy == bv2.numer_lewy)) && ((bv1.numer_prawy == bv2.numer_lewy) || (bv1.numer_prawy == bv2.numer_prawy)))
  62. return true;
  63. else return false;
  64.  
  65. }
  66.  
  67.  
  68. class kartezjanski;
  69.  
  70.  
  71. class sferyczny
  72. {
  73. public:
  74. void B(kartezjanski &A);
  75.  
  76. };
  77.  
  78.  
  79.  
  80. class kartezjanski
  81. {
  82. float x, y, z;
  83. public:
  84.  
  85. kartezjanski(double X=1.0, double Y=1.0, double Z=1.0)
  86. {
  87. this->x = X;
  88. this->y = Y;
  89. this->z = Z;
  90.  
  91. }
  92.  
  93. void wyswietlKartezjanski()
  94. {
  95. cout << this->x << " " << this->y << " " << this->z << endl;
  96.  
  97. }
  98. friend void sferyczny::B(kartezjanski &A);
  99. };
  100.  
  101. void sferyczny::B(kartezjanski &A)
  102. {
  103. double fi = sqrt(pow(A.x, 2) + pow(A.y, 2));
  104. double ro = acos(A.x / fi);
  105.  
  106. cout << fi << " " << ro << " "<<A.z<< endl;
  107.  
  108. }
  109.  
  110.  
  111. int main()
  112. {
  113. domino v1(2, 5);
  114. domino v2(5, 4);
  115. domino v3(2, 3);
  116. domino v4(5, 2);
  117. sferyczny example;
  118.  
  119. kartezjanski example1(45,45,3);
  120.  
  121. example.B(example1);
  122.  
  123.  
  124. v1.display();
  125. v2.display();
  126. v3.display();
  127.  
  128. if (v1 == v4)
  129. {
  130. cout << "Ta" << endl;
  131. }
  132. else
  133. cout << "Nope" << endl;
  134.  
  135. if (v1.mozna(v2)==true)
  136. {
  137. cout << "Mozna, jeszcze jak" << endl;
  138. domino::add(v1, v2);
  139. v1.display();
  140. }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement