Advertisement
szmelu

zaj9

Dec 20th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. ########################
  2. #pragma once
  3. #include <iostream>
  4. #include <string>
  5. #include <cstdlib>
  6. #include <ctime>
  7. using namespace std;
  8. class Osoba {
  9. protected:
  10. static int licznik_id;
  11. static int licznik_ilosc;
  12. int id;
  13. string dane;
  14. public:
  15. Osoba();
  16. virtual ~Osoba();
  17. virtual void wypisz()=0;
  18. static int getLicznik();
  19.  
  20. };
  21. ########################
  22. #include "Osoba.h"
  23. class Prowadzacy
  24. :public Osoba
  25. {
  26. string cecha = "dr inz.";
  27. public:
  28. Prowadzacy();
  29. ~Prowadzacy();
  30. virtual void wypisz();
  31. };
  32. ########################
  33. #include "Osoba.h"
  34. class Student
  35. :public Osoba
  36. {
  37. double ocena[3];
  38. public:
  39. Student();
  40. ~Student();
  41. virtual void wypisz();
  42.  
  43. };
  44. ########################
  45. #include "Osoba.h"
  46. int Osoba::licznik_id = 0;
  47. int Osoba::licznik_ilosc = 0;
  48. Osoba::Osoba()
  49. {
  50.  
  51. }
  52. Osoba::~Osoba()
  53. {
  54.  
  55. }
  56. /*void Osoba::wypisz()
  57. {
  58.  
  59. }*/
  60. int Osoba::getLicznik()
  61. {
  62. return licznik_ilosc;
  63. }
  64. ########################
  65. #include "Prowadzacy.h"
  66. Prowadzacy::Prowadzacy()
  67. {
  68. id = ++licznik_id;
  69. ++licznik_ilosc;
  70. dane = "Jan Kowalski";
  71. }
  72. Prowadzacy::~Prowadzacy()
  73. {
  74. --licznik_ilosc;
  75. }
  76. void Prowadzacy::wypisz()
  77. {
  78. cout << "Prowadzacy: " << dane << " " << cecha;
  79. }
  80. ########################
  81. #include "Student.h"
  82. Student::Student()
  83. {
  84. id = ++licznik_id;
  85. ++licznik_ilosc;
  86. dane = "Adam Nowak";
  87. for (int i = 0; i < 3; i++)
  88. {
  89. ocena[i] = 0.5*(rand() % 7 + 4);
  90. while(ocena[i]==2.5)
  91. ocena[i] = 0.5*(rand() % 7 + 4);
  92.  
  93. }
  94. }
  95. Student::~Student()
  96. {
  97. --licznik_ilosc;
  98. }
  99. void Student::wypisz()
  100. {
  101. cout << id << " " << dane << " Oceny: " << ocena[0] << " " << ocena[1] << " " << ocena[2] << endl;
  102. }
  103. ########################
  104. #include "Prowadzacy.h"
  105. #include "Student.h"
  106. int main()
  107. {
  108. {
  109. srand(time(NULL));
  110. Student *zajecia = new Student[15];
  111. for (int i = 0; i < 15 ; i++)
  112. {
  113. zajecia[i].wypisz();
  114. }
  115. }
  116. cout << Osoba::getLicznik() << endl;
  117. system("pause");
  118. }
  119. ########################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement