MeehoweCK

Untitled

May 4th, 2021
1,097
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class DANE_OSOBOWE
  6. {
  7. protected:
  8.     string imie;
  9.     string nazwisko;
  10.     unsigned wiek;
  11. public:
  12.     DANE_OSOBOWE(string, string, unsigned);
  13.     virtual void wypisz_dane() = 0;
  14. };
  15.  
  16. class STUDENT : public DANE_OSOBOWE
  17. {
  18.     double srednia;
  19.     string kierunek;
  20. public:
  21.     STUDENT(string, string, unsigned, double, string);
  22.     void wypisz_dane();
  23.     double suma_kontrolna();
  24. };
  25.  
  26. class PRACOWNIK : public DANE_OSOBOWE
  27. {
  28.     double wynagrodzenie;
  29.     unsigned przepracowane_lata;
  30. public:
  31.     PRACOWNIK(string, string, unsigned, double, unsigned);
  32.     void wypisz_dane();
  33.     double srednia();
  34. };
  35.  
  36. DANE_OSOBOWE::DANE_OSOBOWE(string name, string scnd_name, unsigned age) : imie(name), nazwisko(scnd_name), wiek(age) {}
  37.  
  38. STUDENT::STUDENT(string name, string scnd_name, unsigned age, double avrg, string topic) : DANE_OSOBOWE(name, scnd_name, age), srednia(avrg), kierunek(topic) {}
  39.  
  40. void STUDENT::wypisz_dane()
  41. {
  42.     cout << imie << ' ' << nazwisko << " (student), wiek: " << wiek << " lata, suma kontrolna = " << suma_kontrolna() << endl;
  43. }
  44.  
  45. double STUDENT::suma_kontrolna()
  46. {
  47.     return srednia / wiek;
  48. }
  49.  
  50. PRACOWNIK::PRACOWNIK(string name, string scnd_name, unsigned age, double sallary, unsigned lata) : DANE_OSOBOWE(name, scnd_name, age), wynagrodzenie(sallary), przepracowane_lata(lata) {}
  51.  
  52. void PRACOWNIK::wypisz_dane()
  53. {
  54.     cout << imie << ' ' << nazwisko << " (pracownik), wiek: " << wiek << " lata, srednie zarobki = " << srednia() << endl;
  55. }
  56.  
  57. double PRACOWNIK::srednia()
  58. {
  59.     return przepracowane_lata * 12 * wynagrodzenie / wiek;
  60. }
  61.  
  62. int main()
  63. {
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment