Bajardi: Qalandarov Javlonbek Gurux: 13-20 Dasturlash fanidan kichik loyihalar yaratish Ishdan maqsad



Yüklə 73,92 Kb.
tarix24.10.2023
ölçüsü73,92 Kb.
#160205
3-Laboratoriya ishi


  1. Laboratoriya ishi

Bajardi:Qalandarov Javlonbek
Gurux:713-20


Dasturlash 2 fanidan kichik loyihalar yaratish
Ishdan maqsad: C++ dasturlash tilining CONSOLE imkoniyatlaridan foydalanib que,deque,stack kabi konteynerlardan mosini tanlab loyiha ma’lumotlari bilan ishlashda qo’llanilsin:

  • turli xil xayotiy (real) jarayonlarni avtomatlashtirish uchun dasturlar yaratish;

  • foydalanuvchilar uchun qulayliklar yaratish maqsadida dastur dizaynini chiroyli va tushunarli xolda dasturlar yaratish;



Ish tartibi:
• Qo'yilgan mavzu bo'yicha kerakli ma'lumotlarni o'rganish, yig’ish va tahlil qilish.
• Berilgan mavzu bo'yicha to'plangan va o'rganilgan ma'lumotlar asosida dastur strukturasini ishlab chiqish.
• C++ dasturlash tilida dasturini yaratish.
• Dasturni ishlatish va testlash.
• Hisobotni tayyorlash.



9

Restoran (joy bron qilish)

Dasturkodi:
#include
#include
#include

class Reservation {


private:
std::string name;
std::string phoneNumber;
std::string date;

public:
Reservation(std::string name, std::string phoneNumber, std::string date) {


this->name = name;
this->phoneNumber = phoneNumber;
this->date = date;
}

std::string getName() const {


return name;
}

std::string getPhoneNumber() const {


return phoneNumber;
}

std::string getDate() const {


return date;
}
};

int main() {


std::deque reservations;

while (true) {


std::cout << "1. Joy bron qilish" << std::endl;
std::cout << "2. Bronni bekor qilish" << std::endl;
std::cout << "3. Bron qilingan joylarni ko'rish" << std::endl;
std::cout << "4. Dasturdan chiqish" << std::endl;
std::cout << "Tanlang: ";
int choice;
std::cin >> choice;

if (choice == 1) {


std::string name, phoneNumber, date;
std::cout << "Ism: ";
std::cin >> name;
std::cout << "Telefon raqam: ";
std::cin >> phoneNumber;
std::cout << "Sana: ";
std::cin >> date;

Reservation reservation(name, phoneNumber, date);


reservations.push_back(reservation);

std::cout << "Joy bron qilindi!" << std::endl;


}
else if (choice == 2) {
if (reservations.empty()) {
std::cout << "Bron qilingan joy mavjud emas!" << std::endl;
}
else {
std::cout << "Bekor qilmoqchi bo'lgan joyning indeksini kiriting: ";
int index;
std::cin >> index;

if (index >= 0 && index < reservations.size()) {


reservations.erase(reservations.begin() + index);
std::cout << "Joy bekor qilindi!" << std::endl;
}
else {
std::cout << "Noto'g'ri indeks kiritildi!" << std::endl;
}
}
}
else if (choice == 3) {
std::cout << "Bron qilingan joylar:" << std::endl;
for (const Reservation& reservation : reservations) {
std::cout << "Ism: " << reservation.getName() << ", Telefon raqam: " << reservation.getPhoneNumber() << ", Sana: " << reservation.getDate() << std::endl;
}
}
else if (choice == 4) {
break;
}
else {
std::cout << "Noto'g'ri tanlov! Iltimos, qaytadan kiriting." << std::endl;
}

std::cout << std::endl;


}

return 0;


}

Yüklə 73,92 Kb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin