Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. class Exceptie
  2. {
  3. char catEx[50], tipEx[50];
  4. public:
  5. Exceptie(char _catEx[], char _tipEx[])
  6. {
  7. strcpy(catEx, _catEx );
  8. strcpy(tipEx, _tipEx );
  9. }
  10. void Print(void)
  11. {
  12. cerr<<"Exceptie ["<<catEx<<"] - "<<tipEx<<endl;
  13. }
  14. };
  15.  
  16. class Persoana
  17. {
  18. protected:
  19. char nume[20], prenume[20], data_n[20]; /*dd.mm.yyyy*/
  20. char _buff[50]; /* utilizat pentru constructii de siruri returnate */
  21. public:
  22. Persoana( char _nume[]="", char _prenume[]="", char _data_n[]="")
  23. {
  24. strcpy(nume, _nume);
  25. strcpy(prenume, _prenume);
  26. strcpy(data_n, _data_n);
  27. }
  28. char* retDataNastere(void)
  29. {
  30. return data_n;
  31. }
  32. char* retNumeComplet(void)
  33. {
  34. strcat(_buff,nume);
  35. strcat(_buff," ");
  36. strcat(_buff,prenume);
  37. return _buff;
  38. }
  39. friend istream& operator>>(istream &c, Persoana &p)
  40. {
  41. cout << "Introduceti numele: " << endl;
  42. cin >> p.nume;
  43. cout << "Introduceti prenumele: " << endl;
  44. cin >> p.prenume;
  45. cout << "Introduceti anul de nastere: " << endl;
  46. cin >> p.data_n;
  47.  
  48. }
  49. };
  50.  
  51.  
  52. class Profesor : public Persoana
  53. {
  54. static int nextID;
  55. int id_prof;
  56. char titlu[20]; /* profesor / conferentiar / s.l. / asistent */
  57. char _buff[50]; /* utilizat pentru constructii de siruri returnate */
  58. public:
  59. Profesor( Persoana &p, char _titlu[]) : Persoana(p), id_prof( ++nextID )
  60. {
  61. if( strcmp(_titlu, "profesor") != 0 && strcmp(_titlu, "conferentiar") != 0
  62. && strcmp(_titlu, "s.l." ) && strcmp(_titlu, "asistent" ) != 0 )
  63. throw Exceptie("PROFESOR", "Titlu incorect"); //Exceptie: titlu incorect
  64.  
  65. strcpy(titlu, _titlu);
  66. }
  67. int getIDProf(void)
  68. {
  69. return id_prof;
  70. }
  71. char* retNumeComplet(void)
  72. {
  73. return strcat( strcat( strcat( strcat( strcpy(_buff, titlu)," "), nume), " "), prenume);
  74. }
  75. };
  76. int Profesor::nextID = 0;/*init membru static*/
  77.  
  78.  
  79. class Student : public Persoana
  80. {
  81. char nr_mat[20]; /*numar matricol*/
  82. char specializ[20]; /*Specializare*/
  83. char _buff[50]; /* utilizat pentru constructii de siruri returnate */
  84. public:
  85. Student(Persoana &_pers, char _nr_mat[], char _spec[]) : Persoana(_pers)
  86. {
  87. strcpy(nr_mat,_nr_mat);
  88. strcpy(specializ,_spec);
  89. }
  90. char* retNumeComplet(void)
  91. {
  92. return strcat( strcat( strcat( strcat( strcpy(_buff, nr_mat)," "), nume), " "), prenume);
  93. }
  94. char* retNrMat(void)
  95. {
  96. return nr_mat;
  97. }
  98. char* retSpec(void)
  99. {
  100. return specializ;
  101. }
  102. };
  103.  
  104. class Disciplina : public Profesor /* profesorului titular*/
  105. {
  106. static int nextID;
  107. int id_disc;
  108. char denumire[20];
  109. char _buff[50];
  110. public:
  111. Disciplina( char _den[], Profesor &p) : Profesor( p )
  112. {
  113. id_disc = ++nextID;
  114. strcpy(denumire, _den);
  115. }
  116. int getIDDisc(void)
  117. {
  118. return id_disc;
  119. }
  120. char* retNumeComplet(void)
  121. {
  122. strcat(_buff,denumire);
  123. strcat(_buff," - ");
  124. strcat(_buff,Profesor::retNumeComplet());
  125. return _buff;
  126. }
  127. char* retProfesor(void)
  128. {
  129. return Profesor::retNumeComplet();
  130. }
  131. };
  132.  
  133. int Disciplina::nextID=0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement