O’zbekiston Respublikasi Axborot Texnologiyalari va
Kommunikatsiyalarni Rivojlantirish Vazirligi
Muhammad Al-Xorazmiy Nomidagi Toshkent Axborot Texnologiyalari Universiteti
Mavzu:Obyektga yo’naltirilgan dasturlash
Topshirdi:Mirzaahmedov Muhammad qodir
Tekshirdi:Rustamova.M.Y
Toshkent 2021
1.topshiriq. Kompyuter monitori va video kartasini class larini yarating va ularni bog’lovchi funksiyalar yarating.
#include
#include
using namespace std;
class Monitor {
private: int narxi;
public: string nomi, xususiyati, rangi;
bool kamera, sensor;
void set_narx(int x) {
narxi = x;
}
int get_narx() {
return narxi;
}
};
class Video {
private: int narxi;
public: string nomi, kompaniya, rangi;
bool karta;
void set_narx(int x) {
narxi = x;
}
int get_narx() {
return narxi;
}
};
Monitor a[1000];
Video b[1000];
int n = 5, m = 5;
void insert_somedata();
void insert_somedata_tel();
void Clear();
void find_products(int cashe) {
int z = 0;
for (int i = 0; i < n; i++) {
if (cashe >= a[i].get_narx()) {
z += 1;
cout << "\n---------------------\n";
cout << z << "-tovar ( N O T E B O O K )";
cout << "\n---------------------\n";
cout << "Video karta nomi: " << a[i].nomi << endl;
cout << "Video karta narxi: " << a[i].get_narx() << endl;
cout << "Video karta xususiyatlari: " << a[i].xususiyati << endl;
}
}
for (int i = 0; i < m; i++) {
if (cashe >= b[i].get_narx()) {
z += 1;
cout << "\n---------------------\n";
cout << z << "-tovar ( )";
cout << "\n---------------------\n";
cout << "Nomi: " << b[i].nomi << endl;
cout << "Narxi: " << b[i].get_narx() << endl;
cout << "Kompaniya: " << b[i].kompaniya << endl;
cout << "IMEI sertifikat -> ";
b[i].karta ? cout << "mavjud" << endl : cout << "mavjud emas" << endl;
}
}
if (z == 0) cout << "Afsuski buncha mablag'ga bizda tovarlar topilmadi...";
};
int main() {
int type_insert, cashe;
cout << "Tovarlarni o'zingiz kiritasizmi yoki mavjud tovarlardan foydalanamizmi? (1-o'zim kiritaman; 2-kiritilgan ma'lumotlardan foydalanish. 2 ni bosish tavsiya etiladi...): "; cin >> type_insert;
if (type_insert == 1) {
cout << "Nechta monitor kiritmoqchisiz: "; cin >> n;
for (int i = 0; i < n; i++) {
int c;
cout << i + 1 << "-monitor nomi: "; cin >> a[i].nomi;
cout << i + 1 << "-monitor xususiyati: "; cin >> a[i].xususiyati;
cout << i + 1 << "-monitor narxi: "; cin >> c; a[i].set_narx(c);
Clear();
}
cout << "Nechta video karta kiritmoqchisiz: "; cin >> m;
for (int i = 0; i < m; i++) {
int c;
cout << i + 1 << "-Video karta nomi: "; cin >> b[i].nomi;
cout << i + 1 << "-Video karta ishlab chiqargan kompaniya: "; cin >> b[i].kompaniya;
cout << i + 1 << "-Video karta kartadan o'rganmi?(1-ha, 0-yo'q): "; cin >> b[i].karta;
cout << i + 1 << "-Video karta narxi: "; cin >> c; a[i].set_narx(c);
Clear();
}
}
else {
insert_somedata();
insert_somedata_tel();
}
Clear();
cout << "O'zingizda bor mablag'ni kiriting men sizga buyum tanlab beraman: "; cin >> cashe;
find_products(cashe);
system("pause>nul");
return 0;
}
void insert_somedata() {
string nomi[1000] = { "Ideapad S340", "Lenovo IdeaPad 3 15ADA05", "Acer Aspire 3 A315-56-594W", "HP ProBook 440 G7", "ASUS 14 X409MA-EB096" };
string xususiyati[1000] = { "Ultrabook, Biznes", "Budjet, Biznes", "Ultrabook", "Budjet, Ofis", "Budjet, Ofis" };
string rangi[1000] = { "Kulrang", "Kulrang", "Qora", "Oq", "Kulrang" };
bool kamera[1000] = { 1,1,0,0,1 };
bool videokarta[1000] = { 1,1,1,1,1 };
bool sensor[1000] = { 1,0,0,0,0 };
bool fingerprint[1000] = { 1,0,0,1,1 };
int narxi[1000] = { 8483000,2500000,6340000,9600000,5495000 };
for (int i = 0; i < 5; i++) {
a[i].nomi = nomi[i];
a[i].xususiyati = xususiyati[i];
a[i].rangi = rangi[i];
a[i].kamera = kamera[i];
a[i].sensor = sensor[i];
a[i].set_narx(narxi[i]);
}
}
void insert_somedata_tel() {
string nomi[1000] = { "Xiaomi Redmi 9A","Apple iPhone 12","Vivo Y20", "Samsung Galaxy S20", "BQ 6022G" };
string kompaniya[1000] = { "Xiaomi", "Apple", "Vivo","Samsung", "BQ" };
string rangi[1000] = { "Siyohrang", "Kulrang", "Ko'k","Oq","Qora" };
bool karta[1000] = { 1,1,0,1,0 };
int narxi[1000] = { 1523000,11760000,1890000,7875000,1087000 };
for (int i = 0; i < 5; i++) {
b[i].nomi = nomi[i];
b[i].kompaniya = kompaniya[i];
b[i].rangi = rangi[i];
b[i].karta = karta[i];
b[i].set_narx(narxi[i]);
}
}
void Clear()
{
#if defined _WIN32
system("cls");
#elif defined (LINUX) || defined(gnu_linux) || defined(linux)
system("clear");
#elif defined (APPLE)
system("clear");
#endif
}
2-topshiriq. Hayvonlar sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.
#include
using namespace std;
class Hayvon{
public:
string nomi;
string joyi;
int yoshi;
string rangi;
string turi;
};
int main()
{Hayvon x;
cout<<"Nomi:";cin>>x.nomi;
cout<<"Yashash joyi:";cin>>x.joyi;
cout<<"Yoshi:";cin>>x.yoshi;
cout<<"Rangi:";cin>>x.rangi;
cout<<"Turi:";cin>>x.turi;
cout<<"Barcha ma'lumotlar"<
cout<<"Nomi "<
cout<<"Yashash joyi "<
cout<<"Yoshi "<
cout<<"Rangi "<
cout<<"Turi "<
3-topshiriq
#include
#include
using namespace std;
class Maydon{
private:
int a;
int b;
int c;
int d;
int e;
int p;
public:
Maydon(){
}
Maydon(int x,int y,int z,int h,int r,int pi )
{a=x;
b=y;
c=z;
d=h;
e=r;
p=pi;
}
int ucburchak(int a,int h)
{
int s;
s=a/2*h;
return s;}
int turtburchak(int a,int b)
{int s1;
s1=a*b;
return s1;
}
int aylana(int p,int e)
{int s2;
s2=p*pow(p,2);
return s2;}
~Maydon(){
}
};
int main()
{int x,y,z,h,r,pi;
cout<<"x ni kriting=";
cin>>x;
cout<<"y ni kriting=";
cin>>y;
cout<<"z ni kriting=";
cin>>z;
cout<<"h ni kriting=";
cin>>h;
cout<<"r ni kriting=";
cin>>r;
cout<<"pi ni kriting=";
cin>>pi;
Maydon ob1;
cout<<"Uchburchakning yuzasi="<
cout<<"Turtburchakning yuzasi="<
cout<<"Aylananing yuzasi="<
return 0;
}
4-topshiriq. Tovarlar ro’yxati quyidagilardan iborat. Tovar nomi, tovar miqdori, narxi va tovarning omborga kelib tushgan vaqti. Narxi 10000 so’mdan oshiq va bir oydan ko’proq saqlanayotgan tovarlar ro’yxatini chiqarish.
#include
using namespace std;
class Tovarlar{
public:
string nomi;
string miqdori;
float narxi;
int vaqti;
public:
Tovarlar(){
nomi="Tovarlar";miqdori="tovarlar";narxi=0;vaqti=0;
}
Tovarlar(string N,string m,float n,int v){
nomi=N; miqdori=m; narxi=n; vaqti=v;
}
void get(){
cout<<"Nomi "; cin>>nomi;
cout<<"Miqdori "; cin>>miqdori;
cout<<"Narxi "; cin>>narxi;
cout<<"Vaqti "; cin>>vaqti;
}
void show(){
cout<<"Nomi "<
cout<<"Miqdori "<
cout<<"Narxi "<
cout<<"Vaqti "<
}
};
int main(){
Tovarlar t[100];
int a;
cout<<"Turining miqdorini kriting: ";
cin>>a;
for(int i=0;icout<
t[i].get();
}
cout<<"Narxi 10000 so'mdan ortiq va omborda 30 kundan ortiq saqlangan tovarlar:"<
for(int i=0;i
if(t[i].narxi>10000 and t[i].vaqti>30){
cout<
t[i].show();
}
}
}
Do'stlaringiz bilan baham: |