You are on page 1of 5

#include <iostream>

#include <stdio.h>
#include <string.h>
using namespace std;

class student
{
char * name;
char * firstname;
char * specialitatea;
int anul;
float nota;
public:
student(char A[5]="Name", char B[9]="Firstname", char C[14]="Specialitatea",
int an=0, float nota=0);
~student();
void Afisez();
void Info(char *Nume, char * Prenume, char * Spec, int & an, float &nota);
int Anul();
float Nota();
};

student::~student()
{
delete name;
delete firstname;
delete specialitatea;
system("pause");
}

int student::Anul()
{
return anul;
}

float student::Nota()
{
return nota;
}

void student::Info(char Nume[], char Prenume[], char Spec[], int &an, float &nota)
{
strcpy(Nume, name);
strcpy(Prenume, firstname);
strcpy(Spec, specialitatea);
an = anul;
nota = nota;
}

class student_diplomant : public student


{
student * S;
char * tema;
public:
student_diplomant(char A[5]="Name", char B[9]="Firstname", char
C[14]="Specialitatea", int an=0, float nota=0, char D[5]="Tema");
~student_diplomant();
void AfisezD();
void GetInfo();
float ComparareStd();
};

student_diplomant::~student_diplomant()
{
delete tema;
}

float student_diplomant::ComparareStd()
{
return S->Nota();
}

void student_diplomant::GetInfo()
{
bool executie;
char num[40], pren[40], spec[50];
char tems[50];
int an;
float nota;
S->Info(num, pren, spec, an, nota);
cout << "Doriti sa modificati numele ? (1 - Da, 0 - Nu)" << endl;
cin >> executie;
if(executie==1)
{
cout << "Introduce numele :" ;
cin >> num;
}
cout << "Doriti sa modificati prenumele ? (1 - Da, 0 - Nu)" << endl;
cin >> executie;
if(executie==1)
{
cout << "Introduce prenumele :" ;
cin >> pren;
}
cout << "Doriti sa modificati specialitatea ? (1 - Da, 0 - Nu)" << endl;
cin >> executie;
if(executie==1)
{
cout << "Introduce specialitatea :" ;
cin >> spec;
}
cout << "Doriti sa modificati anul ? (1 - Da, 0 - Nu)" << endl;
cin >> executie;
if(executie==1)
{
cout << "Introduce anul :" ;
cin >> an;
}
cout << "Doriti sa modificati nota ? (1 - Da, 0 - Nu)" << endl;
cin >> executie;
if(executie==1)
{
cout << "Introduce nota :" ;
cin >> nota;
}
if(an==4)
{
cout << "Doriti sa modificati tema diplomei ? (1 - Da, 0 - Nu)" << endl;
cin >> executie;
if(executie==1)
{
cout << "Introduce tema de diploma :" ;
cin >> tems;
tema = new char[strlen(tems)+1];
strcpy(tema, tems);
}
}
S= new student(num, pren, spec, an, nota);
}

student_diplomant::student_diplomant(char *A, char *B, char *C, int an, float nota,
char *D)
{
S = new student(A, B, C, an, nota);
tema = new char[strlen(D)+1];
strcpy(tema, D);
}

void student_diplomant::AfisezD()
{
S->Afisez();
if(S->Anul()==4)
{
cout << "Tema diplomei este :\t\t" << tema << endl;
}
}

student::student(char *A, char *B, char *C, int an, float nota)
{
name=new char[strlen(A)+1];
strcpy(name, A);
firstname=new char[strlen(B)+1];
strcpy(firstname, B);
specialitatea=new char[strlen(C)+1];
strcpy(specialitatea, C);
anul=an;
nota=nota;
}

void student::Afisez()
{
cout << "Numele studentului este : \t" << firstname << endl;
cout << "Prenumele studentului este : \t" << name << endl;
cout << "Specialitatea studentului este :" << specialitatea << endl;
cout << "Anul studentului este : \t" << anul << endl;
cout << "Nota studentului este : \t" << nota << endl;
}

int main()
{
int n, exec;
int k;
float max;
bool executie;
char Nume[30], Prenume[30], Specialitatea[30], Tema[50];
int an;
float nota;
cout << "Introduceti numarul de studenti :" << endl;
cin >> n;
student_diplomant *s = new student_diplomant[n];
for(int i=0; i<n; i++)
{
system("cls");
cout << "Introduceti numele studentului :"<< endl;
cin >> Nume;
cout << "Introduceti prenumele studentului :"<< endl;
cin >> Prenume;
cout << "Introduceti specialitatea studentului :"<< endl;
cin >> Specialitatea;
cout << "Introduceti anul studentului : "<< endl;
cin >> an;
cout << "Introduceti nota studentului :" << endl;
cin >> nota;
if (an == 4)
{
cout << "Introduceti Tema diplomei a studentului :"<< endl;
cin >> Tema;
s[i]=student_diplomant(Nume, Prenume, Specialitatea, an, nota, Tema);
} else
{
s[i]=student_diplomant(Nume, Prenume, Specialitatea, an, nota);
}
}
do
{
system("cls");
cout << "\t\t>>MENU<<\t\t"<< endl;
cout << "1) Afisez informatia " << endl;
cout << "2) Schimbare a datelor unui student:" << endl;
cout << "3) Compararea studentilor dupa nota :" << endl;
cout << "0) Exit" << endl;
cin >> exec;
switch(exec)
{
case 1 :
{
system("cls");
for(int i=0; i<n; i++)
{
cout << "Informatia despre studentul nr : " << i+1<< endl;
s[i].AfisezD();
cout << endl;
}
}
break;
case 2 :
{
system("cls");
cout << "Alegeti studentul la care doriti sa schimbati informatia "
<< endl;
system("pause");
for(int i=0; i<n; i++)
{
system("cls");
s[i].AfisezD();
cout << "Doriti sa modificati informatia despre student ? (1-
Da, 0-Nu)" << endl;
cin >> executie;
if(executie==1)
{
s[i].GetInfo();
}
}
}
break;
case 3: {
system("cls");
max = s[0].ComparareStd();
k=0;
for(int i=0; i<n; i++)
{
if (s[i].ComparareStd()>max)
{
k=i;
max = s[i].ComparareStd();
}
}
cout << "Studentul cu cel mai mare nota este :" << endl;
s[k].AfisezD();
}
break;
case 0:
{
system("cls");
delete []s;
}
}
system("pause");
}
while(exec!=0);
s[0].AfisezD();
s[1].AfisezD();
return 0;
}

You might also like