soulrpg

obiektowe2_2_unfinished

Oct 21st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Kwadrat;
  6. class Punkt{
  7. private:
  8.     double x;
  9.     double y;
  10. public:
  11.     void set_x(double new_x){
  12.         x = new_x;
  13.     }
  14.     void set_y(double new_y){
  15.         y = new_y;
  16.     }
  17.     double get_x(){
  18.         return x;
  19.     }
  20.     double get_y(){
  21.         return y;
  22.     }
  23.     friend class Kwadrat;//void Kwadrat::set_lewo_gora(Punkt);
  24. };
  25. class Kwadrat{
  26. private:
  27.     Punkt lewo_gora;
  28.     double bok;
  29. public:
  30.     void set_lewo_gora(Punkt punkt){
  31.        lewo_gora.x = punkt.get_x();
  32.        lewo_gora.y = punkt.get_y();
  33.     }
  34.     void set_bok(double new_bok){
  35.         bok = new_bok;
  36.     }
  37.     Kwadrat operator+(Kwadrat);
  38.     Kwadrat operator-(Kwadrat);
  39. };
  40.  
  41.  
  42.  
  43.  
  44.  
  45. Kwadrat Kwadrat::operator+(Kwadrat inny){
  46.     Kwadrat nowy;
  47.     nowy.set_lewo_gora(lewo_gora);
  48.     nowy.set_bok(bok+inny.bok);
  49.     return nowy;
  50. }
  51.  
  52. Kwadrat Kwadrat::operator-(Kwadrat inny){
  53.     Kwadrat nowy;
  54.     nowy.set_lewo_gora(lewo_gora);
  55.     nowy.set_bok(bok-inny.bok);
  56.     return nowy;
  57. }
  58.  
  59. int main()
  60. {
  61.     Kwadrat k1, k2;
  62.     cout << "Podaj"
  63.     cin.sync();
  64.     cin.get();
  65.     return 0;
  66. }
Add Comment
Please, Sign In to add comment