Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Exceptie
- {
- char catEx[50], tipEx[50];
- public:
- Exceptie(char _catEx[], char _tipEx[])
- {
- strcpy(catEx, _catEx );
- strcpy(tipEx, _tipEx );
- }
- void Print(void)
- {
- cerr<<"Exceptie ["<<catEx<<"] - "<<tipEx<<endl;
- }
- };
- class Persoana
- {
- protected:
- char nume[20], prenume[20], data_n[20]; /*dd.mm.yyyy*/
- char _buff[50]; /* utilizat pentru constructii de siruri returnate */
- public:
- Persoana( char _nume[]="", char _prenume[]="", char _data_n[]="")
- {
- strcpy(nume, _nume);
- strcpy(prenume, _prenume);
- strcpy(data_n, _data_n);
- }
- char* retDataNastere(void)
- {
- return data_n;
- }
- char* retNumeComplet(void)
- {
- strcat(_buff,nume);
- strcat(_buff," ");
- strcat(_buff,prenume);
- return _buff;
- }
- friend istream& operator>>(istream &c, Persoana &p)
- {
- cout << "Introduceti numele: " << endl;
- cin >> p.nume;
- cout << "Introduceti prenumele: " << endl;
- cin >> p.prenume;
- cout << "Introduceti anul de nastere: " << endl;
- cin >> p.data_n;
- }
- };
- class Profesor : public Persoana
- {
- static int nextID;
- int id_prof;
- char titlu[20]; /* profesor / conferentiar / s.l. / asistent */
- char _buff[50]; /* utilizat pentru constructii de siruri returnate */
- public:
- Profesor( Persoana &p, char _titlu[]) : Persoana(p), id_prof( ++nextID )
- {
- if( strcmp(_titlu, "profesor") != 0 && strcmp(_titlu, "conferentiar") != 0
- && strcmp(_titlu, "s.l." ) && strcmp(_titlu, "asistent" ) != 0 )
- throw Exceptie("PROFESOR", "Titlu incorect"); //Exceptie: titlu incorect
- strcpy(titlu, _titlu);
- }
- int getIDProf(void)
- {
- return id_prof;
- }
- char* retNumeComplet(void)
- {
- return strcat( strcat( strcat( strcat( strcpy(_buff, titlu)," "), nume), " "), prenume);
- }
- };
- int Profesor::nextID = 0;/*init membru static*/
- class Student : public Persoana
- {
- char nr_mat[20]; /*numar matricol*/
- char specializ[20]; /*Specializare*/
- char _buff[50]; /* utilizat pentru constructii de siruri returnate */
- public:
- Student(Persoana &_pers, char _nr_mat[], char _spec[]) : Persoana(_pers)
- {
- strcpy(nr_mat,_nr_mat);
- strcpy(specializ,_spec);
- }
- char* retNumeComplet(void)
- {
- return strcat( strcat( strcat( strcat( strcpy(_buff, nr_mat)," "), nume), " "), prenume);
- }
- char* retNrMat(void)
- {
- return nr_mat;
- }
- char* retSpec(void)
- {
- return specializ;
- }
- };
- class Disciplina : public Profesor /* profesorului titular*/
- {
- static int nextID;
- int id_disc;
- char denumire[20];
- char _buff[50];
- public:
- Disciplina( char _den[], Profesor &p) : Profesor( p )
- {
- id_disc = ++nextID;
- strcpy(denumire, _den);
- }
- int getIDDisc(void)
- {
- return id_disc;
- }
- char* retNumeComplet(void)
- {
- strcat(_buff,denumire);
- strcat(_buff," - ");
- strcat(_buff,Profesor::retNumeComplet());
- return _buff;
- }
- char* retProfesor(void)
- {
- return Profesor::retNumeComplet();
- }
- };
- int Disciplina::nextID=0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement