Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ########################
- #pragma once
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- class Osoba {
- protected:
- static int licznik_id;
- static int licznik_ilosc;
- int id;
- string dane;
- public:
- Osoba();
- virtual ~Osoba();
- virtual void wypisz()=0;
- static int getLicznik();
- };
- ########################
- #include "Osoba.h"
- class Prowadzacy
- :public Osoba
- {
- string cecha = "dr inz.";
- public:
- Prowadzacy();
- ~Prowadzacy();
- virtual void wypisz();
- };
- ########################
- #include "Osoba.h"
- class Student
- :public Osoba
- {
- double ocena[3];
- public:
- Student();
- ~Student();
- virtual void wypisz();
- };
- ########################
- #include "Osoba.h"
- int Osoba::licznik_id = 0;
- int Osoba::licznik_ilosc = 0;
- Osoba::Osoba()
- {
- }
- Osoba::~Osoba()
- {
- }
- /*void Osoba::wypisz()
- {
- }*/
- int Osoba::getLicznik()
- {
- return licznik_ilosc;
- }
- ########################
- #include "Prowadzacy.h"
- Prowadzacy::Prowadzacy()
- {
- id = ++licznik_id;
- ++licznik_ilosc;
- dane = "Jan Kowalski";
- }
- Prowadzacy::~Prowadzacy()
- {
- --licznik_ilosc;
- }
- void Prowadzacy::wypisz()
- {
- cout << "Prowadzacy: " << dane << " " << cecha;
- }
- ########################
- #include "Student.h"
- Student::Student()
- {
- id = ++licznik_id;
- ++licznik_ilosc;
- dane = "Adam Nowak";
- for (int i = 0; i < 3; i++)
- {
- ocena[i] = 0.5*(rand() % 7 + 4);
- while(ocena[i]==2.5)
- ocena[i] = 0.5*(rand() % 7 + 4);
- }
- }
- Student::~Student()
- {
- --licznik_ilosc;
- }
- void Student::wypisz()
- {
- cout << id << " " << dane << " Oceny: " << ocena[0] << " " << ocena[1] << " " << ocena[2] << endl;
- }
- ########################
- #include "Prowadzacy.h"
- #include "Student.h"
- int main()
- {
- {
- srand(time(NULL));
- Student *zajecia = new Student[15];
- for (int i = 0; i < 15 ; i++)
- {
- zajecia[i].wypisz();
- }
- }
- cout << Osoba::getLicznik() << endl;
- system("pause");
- }
- ########################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement