3- variant. Noma’lum turlar va noma’lum nomlar fazosi
Download 89.33 Kb.
|
Dasturlash2.lab1.3v
- Bu sahifa navigatsiya:
- Class lar o’rtasida vorislikni tashkil qilish. Overriding va overloading bo’ladigan funksiyalarni yaratish
1- LABORATORIYA ISHI OBYEKTGA YO’NALTIRILGAN DASTURLASH 3- variant. Noma’lum turlar va noma’lum nomlar fazosi Telefon va notebook class larini yarating va ularni bog’lovchi funksiyalar yarating Dastur ko’di: // Telefon va notebook classlarini bog'lovchi funksiyalar #include using namespace std; class mobile { private:
int makeyear; int hotirasi; public: mobile ( int makeyear, int hotirasi){ this ->makeyear=makeyear; this ->hotirasi=hotirasi; } virtual int getmakeyear (){ return makeyear; } virtual int gethotirasi (){ return hotirasi; } }; class Telefon : public mobile { public:
Telefon ( int makeyear, int hotirasi) : mobile (makeyear, hotirasi){} }; class Notebook : public mobile { public: Notebook (int makeyear, int hotirasi) : mobile ( makeyear , hotirasi){} }; int main (){ Telefon Tel= Telefon (2019,16); Notebook Note= Notebook (2016, 1000); cout<<"\n _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-\n"; cout<<" chiqilgan yili : "< cout<<" telefon xotirasi GB : "< cout<<"_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-\n"; cout<<" ishlab chiqilgan yili : "< cout<<" notebook xotirasi GB : "< cout<<"_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-\n";
}
kun, oy,yil nomi, ishlab chiqarilgan sanasi, ishlab chiqarish firmasi #include #include using namespace std; class Day {
private: int sana, oy, yil; public:
Day (int san, int o,int y){ sana=san; oy=o; yil= y; } int getoy (){ return oy; } int getyil(){ return yil; }
Day (){} };
class Dori { string dorinomi, firmasi; int chsana, choy, chyil;
public:
dorinomi=d; firmasi= f; chsana= sa; choy= oy; chyil=yil; } string getdorinomi (){ return dorinomi; }
string getfirmasi (){ return firmasi; } int getchsana (){ return chsana; }
int getchoy (){ return choy; } int getchyil(){ return chyil; }
Dori (){} };
class Kun : public Dori , public Day { Day day; Dori dori; public:
Kun ( Day day, Dori dori ){ } void Sana (){ int q=0; q= (day.getyil()- dori.getchyil())*366+(day.getoy()-dori.getchoy())*30+(day.getsana()-dori.getchsana()); cout<<"\n\n"; if (q) { cout<<"Dori nomi : "< }
else cout<<" Siz sanani hatoni kiritdingiz hali dori chiqman :) \n\n"; }; int main (){ string dor, fir; int aa,bb,cc; int dd,ee,ff; cout<<"\n\n "; cout<<" dori nomini kiriting : "; cin>>dor; cout<<" dori firmasini kiriting : "; cin>>fir; cout<<" dorining chiqgan yilni kiriting : "; cin>>aa; cout<<" dorining chiqgan oyini kiriting : "; cin>>bb; cout<<" dorining chiqgan sanasini kiriting: "; cin>>cc; cout<<"============================================================\n\n"; cout<<" bugungi sanani kiriting : "; cin>>dd; cout<<" bu oyni kiriting : "; cin>>ee; cout<<" bu yilni kiritng : "; cin>>ff; cout<<"============================================================\n\n"; Dori dori(dor, fir,cc, bb,aa); Day day (dd, ee,ff); Kun kun (day, dori ); kun.Sana(); }
Download 89.33 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling