Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. const int ILOSC = 6;
  4.  
  5. class Pociag {
  6.     friend class Pociag_os;
  7.     friend class Pociag_tow;
  8. private:
  9.     string nazwa;
  10.     string kolor;
  11.     int wagony;
  12. public:
  13.     Pociag() {
  14.         nazwa = "pociag1";
  15.         kolor = "kolor1";
  16.         wagony = 5;
  17.     }
  18.     Pociag(string nazwa, string kolor, int wagony) {
  19.         this->nazwa = nazwa;
  20.         this->kolor = kolor;
  21.         this->wagony = wagony;
  22.     }
  23.     string nazwa_return() {
  24.         return nazwa;
  25.     }
  26.     string kolor_return() {
  27.         return kolor;
  28.     }
  29.     int wagony_return() {
  30.         return wagony;
  31.     }
  32.     void pokaz_opis() {
  33.         cout << "Dane Pociagu:\n";
  34.     // do zrobienia
  35.     }
  36. };
  37.  
  38. class Pociag_os : public Pociag {
  39.    
  40. private:
  41.     int liczba_miejsc;
  42. public:
  43.     Pociag_os(){
  44.     }
  45.     Pociag_os(string nazwa, string kolor, int wagony, int liczba_miejsc) {
  46.         this->nazwa = nazwa;
  47.         this->kolor = kolor;
  48.         this->wagony = wagony;
  49.         this->liczba_miejsc = liczba_miejsc;
  50.     }
  51.     int miejsca_return() {
  52.         return liczba_miejsc;
  53.     }
  54. };
  55. class Pociag_tow : public Pociag {
  56. private:
  57.     int ladownosc;
  58. public:
  59.     Pociag_tow() {
  60.     }
  61.     Pociag_tow(string nazwa, string kolor, int wagony, int miejsca) {
  62.         this->nazwa = nazwa;
  63.         this->kolor = kolor;
  64.         this->wagony = wagony;
  65.         this->ladownosc = ladownosc;
  66.     }
  67.     int ladownosc_return() {
  68.         return ladownosc;
  69.     }
  70. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement