Facebook
From Toxic Octupus, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 242
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. class Person
  7. {
  8.     string name;
  9.     int date;
  10.  
  11. public:
  12.  
  13.     void setName(string name)
  14.     {
  15.         this->name=name;
  16.     }
  17.     void setDate(int date)
  18.     {
  19.         this->date=date;
  20.     }
  21.  
  22.     string getName()
  23.     {
  24.         return this->name;
  25.     }
  26.  
  27.     int getDate()
  28.     {
  29.         return this->date;
  30.     }
  31.  
  32.     Person()
  33.     {
  34.     }
  35.  
  36.     Person(string name, int date)
  37.     {
  38.         this->name=name;
  39.         this->date=date;
  40.     }
  41.  
  42.     Person ( Person &coppy)
  43.     {
  44.         this->name = coppy.getName();
  45.         this->date = coppy.getDate();
  46.     }
  47.  
  48.  
  49.  
  50.  
  51.     int age()
  52.     {
  53.       this->date=date;
  54.  
  55.       int wiek = 0;
  56.  
  57.       int rok = 2018;
  58.  
  59.       wiek = rok - date;
  60.  
  61.       if(wiek < 0 || wiek>100)
  62.       {
  63.           cout<<"Taka osoba nie zyje :) "<<endl;
  64.       }
  65.       else
  66.     {
  67.     cout<<"Wiek wynosi : "<<wiek<<endl;
  68.     }
  69.  
  70.         return 0;
  71.     }
  72.  
  73.     void show()
  74.     {
  75.         cout<<this->name<<endl;
  76.         cout<<this->date<<endl;
  77.     }
  78. };
  79.  
  80.  
  81.  
  82.  
  83. int main()
  84. {
  85. /*
  86.     Person osoba;
  87.  
  88.  
  89.     osoba.setName("Daniel");
  90.     osoba.setDate(1991);
  91.  
  92.     osoba.show();
  93.  
  94.  
  95.  
  96. Person osoba2;
  97.     osoba2.setName("Konrad");
  98.     osoba2.setDate(1791);
  99.  
  100.     osoba2.show();
  101.     osoba2.age();
  102.  
  103.     Person osoba3(osoba2);
  104.     daniel.show();
  105.     Person osoba4(osoba2);
  106.     Person osoba5(osoba2);
  107. */
  108. string name;
  109. int date;
  110.         const int n = 5;
  111.         Person tab[n];
  112.  
  113.         for(int i =0 ;i<n;i++)
  114.         {
  115.             cin>>name;
  116.             cin>>date;
  117.             tab[i].setName(name);
  118.             tab[i].setDate(date);
  119.         }
  120.  
  121.  
  122.         for(int i =0 ;i<n;i++)
  123.         {
  124.             cout<<tab[i].getName();
  125.             cout<<tab[i].getDate();
  126.         }
  127.     return 0;
  128. }
  129.