0% found this document useful (0 votes)
4 views4 pages

Muhammad Al-Xorazminomidagi 217-22-Guruh Talabasi Rofiyev Olamgirningning Dasturlash 2 Fanidan Bajargan Ishi

The document presents a laboratory work assignment focused on object-oriented programming in C++. It involves creating classes for FlashDrive and Disk, along with their associated functions, to enhance skills in organizing unknown namespaces. The provided code demonstrates the implementation of these classes and their usage within a Computer class to display their attributes.

Uploaded by

nebraska0777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Muhammad Al-Xorazminomidagi 217-22-Guruh Talabasi Rofiyev Olamgirningning Dasturlash 2 Fanidan Bajargan Ishi

The document presents a laboratory work assignment focused on object-oriented programming in C++. It involves creating classes for FlashDrive and Disk, along with their associated functions, to enhance skills in organizing unknown namespaces. The provided code demonstrates the implementation of these classes and their usage within a Computer class to display their attributes.

Uploaded by

nebraska0777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Muhammad al-Xorazminomidagi

217-22-guruh talabasi
Rofiyev Olamgirningning
Dasturlash 2 fanidan bajargan ishi

Tekshirdi:Dauletov Adilbek
Bajardi:Rofiyev Olamgir
1- LABORATORIYA ISHI
1. OBYEKTGA YO’NALTIRILGAN
DASTURLASH

Noma’lum turlar va noma’lum nomlar fazosi


Ishning maqsadi: C++ dasturlash tilida obyektga
yo’naltirilgan dasturlash tamoyilaridan foydalanib
noma’lum nomlar fazosini tashkil qilish ko’nikmalarini
shakllantirish.
Masalaning qo’yilishi:
.Fleshka va disk class larini yarating va ularni
bog’lovchi funksiyalar yarating.
Dastur:

#include <iostream>
#include <string>
class FlashDrive {
private:
std::string brand;
int capacity;
public:
FlashDrive(std::string b, int c) {
brand = b;
capacity = c;
}
void display() {
std::cout << "Brand: " << brand << std::endl;
std::cout << "Capacity: " << capacity << " GB"
<< std::endl;
}
};

class Disk {
private:
std::string brand;
int capacity;
public:
Disk(std::string b, int c) {
brand = b;
capacity = c;
}
void display() {
std::cout << "Brand: " << brand << std::endl;
std::cout << "Capacity: " << capacity << " GB"
<< std::endl;
}
};
class Computer {
private:
FlashDrive flashdrive;
Disk disk;
public:
Computer(FlashDrive f, Disk d) : flashdrive(f),
disk(d) {}
void display() {
std::cout << "Flash Drive:" << std::endl;
flashdrive.display();
std::cout << std::endl << "Disk:" << std::endl;
disk.display();
}
};

int main() {
FlashDrive f("Kingston", 32);
Disk d("Seagate", 1000);
Computer c(f, d);
c.display();
return 0;
}

You might also like