204- guruh talabasi Yunusjonov Nosirjonning Programmalash asoslari fanidan laboratoriya ishi tekshirdi: Davirov B. Samarqand 2022



Download 48,65 Kb.
bet1/3
Sana14.12.2022
Hajmi48,65 Kb.
#885879
  1   2   3
Bog'liq
labart


O’ZBEKISTON RESPUBLIKASI


OLIY VA O’RTA-MAXSUS TA’LIM VAZIRLIGI
SAMARQAND DAVLAT UNIVERSITETI
RAQAMLI TEXNOLOGIYALAR FAKULTETI


DASTURIY INJINIRING YO’NALISHI
204- guruh talabasi
Yunusjonov Nosirjonning
Programmalash asoslari fanidan
LABORATORIYA ISHI
Tekshirdi: Davirov B.
SAMARQAND - 2022

11-LABORATORIYA MASHG’ULOTI. VORISLIKDA KONSTRUKTOR VA DESTRUKTORLAR

Device (Qurilma) va Telephone (telefon), Computer (Kompyuter) sinflari hosil qiling. Avlod sinflar ajdod sinfidan meros olgan olgan holda qo’shimcha metodlar hosil qiling.

#include


using namespace std ;

class Device{


public:
string name ;
int date ;
};

class Telephone:public Device{


public:
string os ;
int ram ;
};

class Computer:public Device{


public:
int rom ;
};

int main(){


Telephone obj1 ;
cout << "Siz qaysi OS dan foydalanasiz " ;
cin >> obj1.os ;
Computer obj2 ;
cout << "Kompyuter chiqarilgan sanasi : " ;
cin >> obj2.date ;
cout <<"Sizning qurilmangiz " << obj1.os << endl ;
cout << "Kompyuteringiz "<< obj2.date <<" yilda chiqqan";
}

Organization (Tashkilot) va Bank (Bank), School (Maktab) sinflari hosil qiling. Avlod sinflar ajdod sinfidan meros olgan olgan holda qo’shimcha metodlar hosil qiling.

#include


using namespace std ;

class Organization{


public:
int type;
int location;
};

class Bank:public Organization{


public:
double money ;
string name ;
};

class School:public Organization{


public:
int school_num ;
int man ;
};

int main(){


Organization obj1;
School obj4 , obj5 ;
Bank obj2 ; Bank obj3;
cout << "[1] - Bank tashkiloti "< cout << "[2] - Maktab tashkiloti " << endl ;
cin >> obj1.type ;
switch(obj1.type){

case 1 :
cout << "Bank nomi nima ? " ; cin >> obj3.name ;
cout << "Bankda qancha pul bor ? " ; cin >> obj2.money ;
cout << "Bank nomi " << obj3.name << endl ;
cout << "Bankda " << obj2.money <<"$ pul bor" ; break ;

case 2 :
cout <<"Maktab raqami :" ; cin >> obj4.school_num ;
cout << "O'quvchi soni : " ; cin >> obj5.man ;
cout < default : cout << "1 yoki 2 kirit" ; break ;
}}
SportClub (Sport klub) va FootballClub (Futbol klubi), BasketballClub(Basketbol klubi) sinflari hosil qiling. Avlod sinflar ajdod sinfidan meros olgan olgan holda qo’shimcha metodlar hosil qiling.

#include


using namespace std ;

class SportClub{


public:
string name ;
int players;
int referee;
};

class FootballClub:public SportClub{


public:
string club_name ;
int vs ;
};

class BasketballClub:public SportClub{


public:
int man ;
};

int main(){


SportClub obj1 ;
FootballClub obj2;
BasketballClub obj3 ;
cout << "Futbolda nechi kishi o'ynaydi ?" << endl ;
cin >> obj1.players ;
if(obj1.players!=11){
cout << "11 kishi o'ynaydi futbolda " << endl ;
}
else
cout << "Topdiz ! " << endl ;

cout << "Real kuchlimi barsami" << endl ;
cout << "[1] - Real MAdrid " << endl ;
cout << "[2] - Barcelona " << endl ;
cin >> obj2.vs ;
if(obj2.vs==1){
cout << "Tabriklaymiz to'g'ri yo'ldasiz" << endl ;
}
else
cout << "Katta xato javob" << endl ;

cout << "Bassketbolda nechi kishi o'ynaydi ? " ; cin >> obj3.man ;

if(obj3.man==5){
cout << "Barakalla !!!" ;
}
else
cout << "5 kishi o'ynaydi" ;
}


12-LABORATORIYA MASHG’ULOTI. KOMPOZITSIYA VA VORISLIK. ODDIY VA KO'PLIKDAGI VORISLIK

Shape (Shakl) va Triangle (Uchburchak) sinflari hosil qiling. Triangle sinfidan meros olgan RightAngledTriangle (To’g’ri burchakli uchburchak), Equilateral triangle(Teng yonli uchburchak) sinfini hosil qiling. Avlod sinfga qo’shimcha metodlar hosil qiling .

#include


#include
using namespace std ;

class Shape{


public:
string shape = "Shakllar" ;
};

class Triangle{


public:
double a_angled ;
double b_angled ;
double c_angled ;
};

class RightAngledTriangle:public Triangle{


public:
};

class EquilateralTriangle:public Triangle{


public:
};

int main(){


Triangle a_katet ;
Triangle b_katet ;
Triangle c_katet ;
cout << "a katet : " ; cin >> a_katet.a_angled ;
cout << "b katet : " ; cin >> b_katet.b_angled ;
cout << "c katet : " ; cin >> c_katet.c_angled ;

if((pow(a_katet.a_angled,2)+pow(b_katet.b_angled,2))==pow(c_katet.c_angled,2)){
cout << "uchburchak to'g'ri burchakli " << endl ;
}
else
cout <<"To'g'ri burchakli emas !!!" << endl ;

if((a_katet.a_angled==b_katet.b_angled && a_katet.a_angled!=c_katet.c_angled) || (a_katet.a_angled==c_katet.c_angled && a_katet.a_angled!=b_katet.b_angled) || b_katet.b_angled==c_katet.c_angled && b_katet.b_angled != a_katet.a_angled){
cout <<"Teng yonli uchburchak" ;
}
else
cout << "Teng yonli emas" ;
}
ElectronDevice (Elektron qurilmalar) va Computer (Kompyuter) sinflari hosil qiling. Computer sinfidan meros olgan Planshet, Notebook, Telephone sinfini hosil qiling. Avlod sinfga qo’shimcha metodlar hosil qiling.

#include


using namespace std ;

class ElectronDevice{


public:
string a = "Qurilmalar" ;
};

class Computer{


public:
string name ;
int date ;
};

class Planshet:public Computer{


public:
int pl_rom ;
};
class Notebook:public Computer{
public:
string comp_os ;
int comp_ram ;
};
class Telephone:public Computer{
public:
int ph_rom ;
int ph_battery ;
};
int main(){
Planshet obj1 ;
Telephone obj2 ;
cout << "telefoningiz operativ xotirasi qancha ? " ; cin >> obj1.pl_rom ;
if(obj1.pl_rom>3){
cout << "Bemalol PES Mobile O'ynasangiz bo'ladi " << endl ;
cout << "Endi Batareyangizni tekshirib ko'ramiz " << endl ;
}
else
cout <<"Telefoningiz operativ xotirasi katta emasligi sabab \no'yin o'ynamasligingizni tavsiya qilaman" << endl ;
cout << "Endi Batareyangizni tekshirib ko'ramiz " << endl ;

cout << "Telefoningiz batareya sig'imi qancha (mHa) :" ; cin >> obj2.ph_battery ;

if(obj2.ph_battery>4000){
cout << "Telefoningiz Batareyasi sig'imi katta ekan " ;
}
else
cout << "Batareya sig'imi katta emas" ;
}
OperationSystem (Operatsion Sistema) va Android, IOS sinflari hosil qiling. Avlod sinfga qo’shimcha metodlar hosil qiling.

#include


using namespace std ;

class OperationSystem{


public:
string name ;
int type ;
int rom ;
int ram ;
int camera ;
int battery ;
};

class Android:public OperationSystem{


public:
void Print(){
cout << "Qurilmangiz : " << name << endl ;
cout << "Qurilma ROM : " << rom << endl ;
cout << "Qurilma RAM : " << ram << endl ;
cout << "Qurilma Camera : " << camera <<" MegaPixel" << endl ;
cout << "Qurilma batareya sig'imi : " << battery ;
}
};

class IOS:public OperationSystem{


public:
};

int main(){


Android obj1 ;
cout << "Qurilma tanlang : " << endl ;
cout << "[1] - Android " << endl ;
cout << "[2] - IOS" << endl ;
cin >> obj1.type ;
switch(obj1.type){
case 1 :
obj1.name = "Android" ;
cout << "Android ROM hajmi ? "; cin >> obj1.rom ;
cout << "Android RAM hajmi ? "; cin >> obj1.ram ;
cout << "Android Camera pixeli ? "; cin >> obj1.camera ;
cout << "Android batareya sig'imi qancha ? "; cin >> obj1.battery ;
obj1.Print();break;
case 2:
obj1.name = "IOS" ;
cout << "IOS ROM hajmi ? "; cin >> obj1.rom ;
cout << "IOS RAM hajmi ? "; cin >> obj1.ram ;
cout << "IOS Camera pixeli ? "; cin >> obj1.camera ;
cout << "IOS batareya sig'imi qancha ? "; cin >> obj1.battery ;
obj1.Print();break;
default: cout << "1 yoki 2 kirit" ; break ;
}
}

13-LABARATORIYA MASHG’ULOTI. SINFLARDA VORIS SINF METODLARIDAN FOYDALANISH

Fruct (Meva) nomli sinf hosil qiling. Undan meros olgan Apple (Olma), Cherry (Gilos), Pear(nok) sinflarini hosil qiling. Avlod sinflar tarkibida mevadagi suv miqdorini, shakar miqdorini qaytaradigan, suv va shakar qismidan tashqari haqiqiy og’irligini qaytaradigan metodlar hosil qiling.

#include


using namespace std;
class Fruct{
public:
string nom;
float suv_miqdor;
float shakar_miqdor;
};
class Applee: public Fruct{
public:
float massa;
};
class Cherry:public Apple{
public:

};
class Pear:public Cherry{


public:
};
int main()
{
Apple obj1;
Cherry obj2;
Pear obj3;
obj1.nom = "Olma";
obj1.shakar_miqdor=100;
obj1.massa = 1000;
obj1.suv_miqdor = 200;

obj2.nom = "Gilos";


obj2.shakar_miqdor=100;
obj2.massa = 800;
obj2.suv_miqdor = 50;

obj3.nom = "Nok";


obj3.shakar_miqdor=100;
obj3.massa = 900;
obj3.suv_miqdor = 200;
cout<<"\nMeva nomi "<cout<cout<<"\nMeva nomi "<cout<cout<<"\nMeva nomi "<return 0;
}

Education (Ta’lim) nomli ajdod sinf hosil qiling. School (Maktab), Kindergarden(Bog’cha), University (Universitet) nomli avlod sinflarni hosil qiling. People (O’quvchi) sinfini hosil qilib, yuqoridagi uchta avlod sinfdan merosxo’rlik olsin. O’quvchining yoshiga, olgan hujjatiga qarab qaysi tashkilot a’zosi ekanligini aniqlash metodi bo’lsin.

#include


using namespace std;
class Education{
public:
int yosh;
};
class School:public Education{
public:
};
class Kindergarden: public Education{
public:
};
class Universitet:public Education{
public:
};
class People:public Education{
public:
};
int main(){
Education obj;
cout << "Yoshingiz : " ; cin >> obj.yosh ;
if(obj.yosh<7){
cout << "Siz Bog'chaga Qatnaysiz " ;
}
else if(obj.yosh>7 && obj.yosh<18){
cout << "Siz Maktabga Borasiz" ;
}
else
cout << "Siz Universitetda O'qiysiz" ;
}

14-LABARATORIYA. POLIMORFIZM PRINSIPINI AMALGA OSHIRISH UCHUN VIRTUAL MEXANIZMLARINI QO’LLASH
Brend, silindrlar soni, quvvat bilan tavsiflangan Car (Avtomobil) ajdod sinfini yarating. Quvvatni qayta tayinlash va o'zgartirish metodlarini aniqlang. Lorry (yuk mashinasi) sinfini yarating, shuningdek, kuzovning yuk ko'tarish qobiliyati xossasini qo‘shing. Brendni qayta belgilash va yuk ko'tarish qobiliyatini o'zgartirish funksiyalarini aniqlang.

#include


using namespace std;
class Car
{
protected:
string m_brend;
int m_Silindr;
int m_power; //Quvvat
public:
Car(string brend, int Silindr, int power)
{
m_brend = brend;
m_Silindr = Silindr;
m_power = power;
}
void setPower(int power)
{
m_power = power;
}
void setPowerN(int n)
{
m_power = n*m_power;
}
int getPower()
{
return m_power;
}
};
class Lorry: public Car
{
protected:
int m_baggage; //Yuk ko'tarish qobiliyati
public:
Lorry(int baggage): Car("Lorry",2,400)
{
m_baggage = baggage;
}
void setBrend(string brend)
{
m_brend = brend;
}
void setBaggage(int baggage)
{
m_baggage = baggage;
}
string getBrend()
{
return m_brend;
}
int getBaggage()
{
return m_baggage;
}};
int main()
{
string brend;
int baggage;
Lorry lorry(2000);
cout<<"Yuk mashinasi brendining nomi "<cout<<"Yangi brend nomini kiriting: ";
getline(cin,brend);
cout<<"Yangi brend nomi: "<cout<<"Yuk ko'tarish qobiliyatini kiriting: ";
cin>>baggage;
lorry.setBaggage(baggage);
cout<<"Yuk ko'tarish qobiliyati: "<return 0;
}

Mashina rusumi, yoqilg’i sarfi, bosib o’tgan masofasi kabi xossalarga ega Car (Avtomobil) ajdod sinfini yarating. Malibu sinfini Car sinfidan meros olgan holda yarating. Mashina rangi, narxi xossalarini qo’shing. Mashina to’lovini qancha muddatda to’lash mumkinligin aniqlash medotini hosil qiling.

#include


#include
using namespace std;
class Car
{
protected:
string m_rusum;
int m_yoqilgi_sarfi;
int m_masofa; //Quvvat
public:
Car(string rusum, int yoqilgi_sarfi, int masofa)
{
m_rusum = rusum;
m_yoqilgi_sarfi = yoqilgi_sarfi;
m_masofa = masofa;
}
};
class Malibu: public Car
{
protected:
string m_rang; //Mashinaning rangi
int m_narx; //Mashinaning narxi
public:
Malibu(string rang, int narx)
: Car("Malibu",3,12000)
{
m_rang = rang;
m_narx = narx;
}
void setrang(string rang)
{
m_rang = rang;
}

void setnarx(int narx)


{
m_narx = narx;
}
string getrang()
{
return m_rang;
}
int getnarx()
{
return m_narx;
}
};
int main()
{
int oylik, muddat;
Malibu malibu("qora", 350000000);
cout<<"Malibuning rangi "<cout<<"Malibuning narxi: "<cout<<"Maoshingiz qanch? "; cin>>oylik;
muddat = malibu.getnarx()/oylik;

cout<<"Siz "<
return 0;
}

Pul summalari bilan ishlash uchun Currency (valyuta) abstrakt sinfini yarating. Rublga konvertatsiya qilishning virtual funktsiyalarini aniqlang va chop eting. Dollar va Evro sinflarini o'zlarining konvertatsiya va chop etish funktsiyalari bilan amalga oshiring.

#include


using namespace std;
class Currency{
public:
float sum;
Currency(float summ)
{
sum = summ;
}
float get_sum()
{
return sum;
}
virtual const string get_value()
{
return "Rubl";
}
virtual const float conversation(float summ)
{
return summ / 150;
}
};
class Dollar: public Currency{
public:
Dollar(float sum):Currency(sum)
{
}
virtual const string get_value()
{
return "Dollar";
}
virtual const float conversation(float summ)
{
return summ / 1100;
}
};
class Euro: public Currency{
public:
Euro(float sum):Currency(sum)
{
}
virtual const string get_value()
{
return "Euro";
}
virtual const float conversation(float summ)
{
return sum / 1150;
}};
void Conversation(Currency ¤cy)
{
cout << currency.get_sum() << " = " << currency.conversation(currency.sum) << " " << currency.get_value() << endl;
}
int main()
{
Currency c(200000);
Dollar dollar1(200000);
Euro euro1(200000);
Conversation(c);
Conversation(dollar1);
Conversation(euro1);
return 0;
}


Download 48,65 Kb.

Do'stlaringiz bilan baham:
  1   2   3




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish