Documente Academic
Documente Profesional
Documente Cultură
#include <string>
using namespace std;// c++
class Profesor {
char* numeProfesor;
string materie;
int nrSalarii;
float* salarii;
int nrClase;
string clase[110];//
};
class Student {
// Student s;
Student() :id(nrStudneti++){
this->note = NULL;
this->nume = new char[strlen("Acest bla bla bla...") + 1];
strcpy(this->nume, "Acest bla bla bla...");
this->facultate = "na";
this->inmatriculat = 0;
this->nrNote = 0;
}
//
//Student s1( "IOnescu ion" csie 1 3
vectnote);
// IOnescu Ion 5 5 69
// yyy csie 1 3 ttt
Student(const char*nu, string fac, bool in, int nrn, int*no) :id(nrStudneti+
+) {
this->nrNote = nrn;
this->note = new int[nrn];
for (int i = 0; i < nrn; i++) {
if (no[i] <= notaMaxima) {
this->note[i] = no[i];
}
else {
note[i] = 10;
}
}
this->nume = new char[strlen(nu) + 1];
strcpy(this->nume, nu);
this->facultate = fac;
this->inmatriculat = in;
}
this->nrNote = nrn;
this->note = new int[nrn];
for (int i = 0; i < nrn; i++) {
if (no[i] <= notaMaxima) {
this->note[i] = no[i];
}
else {
note[i] = 10;
}
}
this->nume = new char[strlen(nu) + 1];
strcpy(this->nume, nu);
this->facultate = fac;
this->inmatriculat = in;
}
// IOnescu Ion
// yyy csie
Student(const char*nu, string fac) :id(nrStudneti++) {
this->note = NULL;
this->nume = new char[strlen(nu) + 1];
strcpy(this->nume, nu);
this->facultate = fac;
this->inmatriculat = 0;
this->nrNote = 0;
}
//Student s4(s2); /// constructor de copiere creaza un obiect pe baza altui
obiect deja existent
// in cazul nostru creaza pe s4 pe baza lui s 2
Student(const Student& sursa) :id(nrStudneti++) {
this->nrNote = sursa.nrNote;
this->note = new int[sursa.nrNote];
for (int i = 0; i < sursa.nrNote; i++) {
this->note[i] = sursa.note[i];
}
this->facultate = sursa.facultate;
this->inmatriculat = sursa.inmatriculat;
}
~Student() {
nrStudneti--;
if (note) {
delete[] note;
}
if (nume) {
delete[] nume;
}
//s=s2
Student& operator=(const Student& sursa) {
//dezalocarea
if (note) {
delete[] note;
}
if (nume) {
delete[] nume;
}
this->nrNote = sursa.nrNote;
this->facultate = sursa.facultate;
this->inmatriculat = sursa.inmatriculat;
return *this;
}
// Student::setNotaPromovare(4);
static void setNrNotaPrommovare(int nota) {
if (nota > 0) {
notaPromovare = nota;
}
}
// s2.setInmatriculare( true);
void setInmatriculare(bool in) {
inmatriculat = in;
}
// id nu facem set
// s2.setFacultate("Agroalimentara");
void setFacultate(string fac) {
if (fac.length() > 2) {
facultate = fac;
}
}
// s2.setNume("Picurel");
void setNume(const char* nu) {
if (strlen(nu) > 2) {
if (nume) {
delete[] nume;
}
this->nume = new char[strlen(nu) + 1];
strcpy(this->nume, nu);
}
}
// setteri
// s2.setNote(2, vectnote);
void setNote(int nrn, int * no) {
if (nrn > 0) {
if (note) {
delete[] note;
}
this->nrNote = nrn;
this->note = new int[nrn];
for (int i = 0; i < nrn; i++) {
this->note[i] = no[i];
}
}
}
char* getNume() {
return nume;
}
string getFacultate() {
return facultate;
}
int getNrNote() {
return nrNote;
}
int* getNote() {
return note;
}
bool getInmatriculare() {
return inmatriculat;
}
int getId() {
return id;
}
//cout<<s2.getMin();
int getMin() {
int min = note[0];
for (int i = 0; i < nrNote) {
if (min > note[1]) {
min = note[i];
}
}
return min;
}
//cout<<s2.getMedie();//metoda generica
float getMedie() {
float m = 0;
for (int i = 0; i < nrNote) {
m += note[i];
}
m = m / nrNote;
return m;
}
// s2.afisare();////metoda generica
void afisare() {
cout << "ID: " << id<<" "<<nume << endl;
cout << "Facultate: " << facultate << endl;
if (inmatriculat == 1) {
cout << "Status: Inamtriculat" << endl;
}
else {
cout << "Status: Neinamtriculat" << endl;
}
cout << "Stundetul are "<<nrNote<<" note, notele: ";
for (int i = 0; i < nrNote; i++) {
cout << note[i] << " ";
}
cout << endl << endl;
// s2.afisare();
friend void afisare1(Student& s) {
cout << "ID: " << s.id << " " << s.nume << endl;
cout << "Facultate: " << s.facultate << endl;
if (s.inmatriculat == 1) {
cout << "Status: Inamtriculat" << endl;
}
else {
cout << "Status: Neinamtriculat" << endl;
}
cout << "Stundetul are " << s.nrNote << " note, notele: ";
for (int i = 0; i < s.nrNote; i++) {
cout << s.note[i] << " ";
}
cout << endl << endl;
void afisare3();
// cout<<s2 <<s3;
friend ostream& operator<<(ostream& o,const Student & s) {
o << "ID: " << s.id << " " << s.nume << endl;
o << "Facultate: " << s.facultate << endl;
if (s.inmatriculat == 1) {
o << "Status: Inamtriculat" << endl;
}
else {
o << "Status: Neinamtriculat" << endl;
}
o << "Stundetul are " << s.nrNote << " note, notele: ";
for (int i = 0; i < s.nrNote; i++) {
o << s.note[i] << " ";
}
o << endl << endl;
return o;
if (s.note) {
delete[] s.note;
}
s.note = new int[s.nrNote];
for (int i = 0; i < s.nrNote; i++) {
cout << "Da nota de pe poztia " << i << ": ";
in >> s.note[i];
}
return in;
}
};
int Student::notaPromovare = 5;
int Student::nrStudneti = 0;
int Student::notaMaxima = 10;
void Student::afisare3() {
cout << "ID: " << id << " " << nume << endl;
cout << "Facultate: " << facultate << endl;
if (inmatriculat == 1) {
cout << "Status: Inamtriculat" << endl;
}
else {
cout << "Status: Neinamtriculat" << endl;
}
cout << "Stundetul are " << nrNote << " note, notele: ";
for (int i = 0; i < nrNote; i++) {
cout << note[i] << " ";
}
cout << endl << endl;
}
void afisare2(Student& s) {
cout << "ID: " << s.id << " " << s.nume << endl;
cout << "Facultate: " << s.facultate << endl;
if (s.inmatriculat == 1) {
cout << "Status: Inamtriculat" << endl;
}
else {
cout << "Status: Neinamtriculat" << endl;
}
cout << "Stundetul are " << s.nrNote << " note, notele: ";
for (int i = 0; i < s.nrNote; i++) {
cout << s.note[i] << " ";
}
cout << endl << endl;
}
void main() {
int a;
//int a = 4;
//int v[3] = {4,4,5};
//int * po;
//po = new int[3];
//po = new int;
Student s, s1;
//cout << &s<<&s1 << endl;
//cout << s1.nrNote;
{
Student sssdsds;
Student::setNotaMaxima(100);
Student::setNrNotaPrommovare(4);
Student::notaPromovare = 5;
// cout << Student::getNotaPromovare() << endl;
// cout << Student::notaPromovare << endl;
// cout << s2 << s1;
cin >> s;
cout << s;