Swd003-L1 Ibragimova Fariza 6-variant 1-laboratoriya ishi


Download 177.54 Kb.
bet3/3
Sana29.04.2020
Hajmi177.54 Kb.
#102197
1   2   3
Bog'liq
1 laboratoriya

using namespace std;

class Fan{

string subject;

int mark;

public:

Fan(string subject, int mark){

this->subject = subject;

this->mark = mark;

}

int getMark(){



return mark; }

};

class Talaba{



string FIO, fakultet, sessiya;

int kurs, stipendiya;

list fan;

public:


Talaba(string fio, string facul, string ses, int ku, list f){

FIO = fio;

fakultet = facul;

sessiya = ses;

kurs = ku;

fan = f;

}

virtual void NextTerm(){



if(kurs == 4){

cout << "Diplom himoyasiga tayyorlaning" << endl;

return;

}

list::iterator it = fan.begin();



bool passed = true;

for(int i = 0; i < fan.size(); i++){

if((*it).getMark() < 3){

passed = false;

}

it++;


}

if(!passed){

cout << "Talaba qayta o'qishga qolgan" << endl;

} else{


cout << "Talaba keyingi semestrga o'tgan" << endl;

}

}



virtual int getStipendiya(){

list::iterator it = fan.begin();

int ball = 5;

for(int i = 0; i < fan.size(); i++){

if((*it).getMark() < ball){

ball = (*it).getMark();

}

it++;


}

switch(ball){

case 3: return 350000;

case 4: return 500000;

case 5: return 650000;

default: return 0;

}

}

virtual void Malumot(){



cout << "Talaba: " << FIO << "\n" << "Fakultet: " << fakultet << "\n" <<

"Kurs: " << kurs << "\n" << "Stipendiya: " << getStipendiya() << " so'm\n";

}

};

class TalabaKontrakt : public Talaba{



string FIO, fakultet, sessiya;

int kurs, stipendiya;

list fan;

bool paid;

public:

TalabaKontrakt(string fio, string facul, string ses, int ku, list f, bool p) : Talaba(fio,facul,ses,ku,f){



FIO = fio;

fakultet = facul;

sessiya = ses;

kurs = ku;

fan = f;

paid = p;

}

void NextTerm() override{



if(!paid){

cout << "Kontrakt to'lanmagan. Keyingi semestrga o'tkazilmadi." << endl;

return;

}

if(kurs == 4){



cout << "Diplom himoyasiga tayyorlaning" << endl;

return;


}

list::iterator it = fan.begin();

bool passed = true;

for(int i = 0; i < fan.size(); i++){

if((*it).getMark() < 3){

passed = false;

}

it++;


}

if(!passed){

cout << "Talaba qayta o'qishga qolgan" << endl;

} else{


cout << "Talaba keyingi semestrga o'tgan" << endl; }

}

int getStipendiya() override{



if(!paid){

return 0; }

list::iterator it = fan.begin();

int ball = 5;

for(int i = 0; i < fan.size(); i++){

if((*it).getMark() < ball){

ball = (*it).getMark();

}

it++;



}

switch(ball){

case 3: return 350000;

case 4: return 500000;

case 5: return 650000;

default: return 0; }

}

string getStatus(){



if(paid){

return "to'langan";

} else{

return "to'lanmagan"; } }

void Malumot() override{

cout << "Talaba: " << FIO << "\n" << "Fakultet: " << fakultet << "\n" < "Kurs: " << kurs << "\n" << "Stipendiya: " << getStipendiya() << " so'm" << "\n"

"Kontrakt: " << getStatus() << endl; } };

list generateVirtualMarks(){

srand(time(0));

list fanlar;

fanlar.push_back(Fan("Calculus", (rand()%4+2)));

fanlar.push_back(Fan("Programming", (rand()%4+2)));

fanlar.push_back(Fan("Physics", (rand()%4+2)));

fanlar.push_back(Fan("English", (rand()%4+2)));

fanlar.push_back(Fan("Academic Writing", (rand()%4+2)));

return fanlar; }

int main(){

Talaba talaba1 = Talaba("Zokirov Alisher Azamovich","KIF","qishki",2,generateVirtualMarks());

Talaba talaba2 = Talaba("Asqarov Javohir Alimovich","AX","yozgi",3,generateVirtualMarks());

TalabaKontrakt talaba3 = TalabaKontrakt("Zokirov Alisher Azamovich","KIF","qishki",2,generateVirtualMarks(),true);

TalabaKontrakt talaba4 = TalabaKontrakt("Asqarov Javohir Alimovich","AX","yozgi",3,generateVirtualMarks(),false);

cout << "Talabalar baholari avtomatik qo'yilmoqda\n" << endl;

cout << "Birinchi talaba -> \n" << endl;

talaba1.NextTerm();

talaba1.Malumot();

cout << "\nIkkinchi talaba -> \n" << endl;

talaba2.NextTerm();

talaba2.Malumot();

cout << "\nUchinchi talaba -> \n" << endl;

talaba3.NextTerm();

talaba3.Malumot();

cout << "\nTo'rtinchi' talaba -> \n" << endl;

talaba4.NextTerm();

talaba4.Malumot();



return 0; }


Download 177.54 Kb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling