Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class domino
- {
- private:
- int numer_lewy, numer_prawy;
- int dlugosc = 1;
- public:
- domino(int lewy = 0, int prawy = 6)
- {
- this->numer_lewy = lewy;
- this->numer_prawy = prawy;
- }
- void display()
- {
- cout << "|" << this->numer_lewy << "( Dlugosc " << this->dlugosc << " )" << this->numer_prawy << "|" << endl;
- }
- static domino add(domino& dodajaca, domino& nowa)
- {
- dodajaca.dlugosc++;
- if (dodajaca.mozna(nowa))
- {
- if (dodajaca.numer_lewy == nowa.numer_prawy)
- {
- dodajaca.numer_lewy = dodajaca.numer_prawy;
- dodajaca.numer_prawy = nowa.numer_lewy;
- }
- else
- dodajaca.numer_prawy = nowa.numer_prawy;
- }
- return dodajaca;
- }
- friend bool operator==(domino& bv1, domino& bv2);
- bool mozna(domino& jeden)
- {
- 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))
- return true;
- else
- return false;
- }
- };
- bool operator==(domino& bv1, domino& bv2)
- {
- 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)))
- return true;
- else return false;
- }
- class kartezjanski;
- class sferyczny
- {
- public:
- void B(kartezjanski &A);
- };
- class kartezjanski
- {
- float x, y, z;
- public:
- kartezjanski(double X=1.0, double Y=1.0, double Z=1.0)
- {
- this->x = X;
- this->y = Y;
- this->z = Z;
- }
- void wyswietlKartezjanski()
- {
- cout << this->x << " " << this->y << " " << this->z << endl;
- }
- friend void sferyczny::B(kartezjanski &A);
- };
- void sferyczny::B(kartezjanski &A)
- {
- double fi = sqrt(pow(A.x, 2) + pow(A.y, 2));
- double ro = acos(A.x / fi);
- cout << fi << " " << ro << " "<<A.z<< endl;
- }
- int main()
- {
- domino v1(2, 5);
- domino v2(5, 4);
- domino v3(2, 3);
- domino v4(5, 2);
- sferyczny example;
- kartezjanski example1(45,45,3);
- example.B(example1);
- v1.display();
- v2.display();
- v3.display();
- if (v1 == v4)
- {
- cout << "Ta" << endl;
- }
- else
- cout << "Nope" << endl;
- if (v1.mozna(v2)==true)
- {
- cout << "Mozna, jeszcze jak" << endl;
- domino::add(v1, v2);
- v1.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement