/
vedeneevt
/
OOP4
Обзор
Документация
Войти
/
vedeneevt
/
OOP4
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
OOP4.cpp
95 строк
2 KB
vedeneev.t
неготовый 4 пункт
19 ноя 2025, 18:18
19 ноя 2025, 18:18
54fc5e0
Код
Авторство
О чём код?
#include <iostream> #include <locale> #include <vector> #include <string> #include <algorithm> using namespace std; /* 1 структура */ struct men { string surname; /* фамилия */ string name; string lastname; /* отчество */ int birthday; men() : birthday(0) {} men(string s, string n, string l, int b) : surname(s), name(n), lastname(l), birthday(b) {} }; /* 2 абстрактный класс */ enum class Category {HudLit, SpravLit, YchLit, Other}; class Book { protected: string title; int pages; vector<men> authors; string publisher; int year; Category category; public: virtual ~Book() = default; void set_title(const string& t) { title = t; } string get_title() const { return title; } }; /* 3 класс книг в каталоге */ class CatalBook : public Book { int id; int total; public: CatalBook(int id = 0 , string t = "" , int p = 0 , int tt = 1 ){ this -> id = id; this -> title = t; this -> pages = p; this -> total = tt; } int get_id() const { return id; } int get_total() const { return total; } }; class RegBook { public: static vector<CatalBook> books; static void add(const CatalBook& b) {books.push_back(b); } static CatalBook* get(int id) { for (auto& b : books) if (b.get_id() == id ) return &b; return nullptr; } static void list(){ for (auto& b : books ) cout << "id" << b.get_id() << " " << b.get_title() << " копий=" << b.get_total() << "\n"; } }; vector<CatalBook> RegBook::books; /* 4 читатель */ class Reader : public men { int reader_id; bool active; vector <int> taken_books; public: Reader ( int id = 0, string s = "" , string n = "" , string l = "" ) { reader_id = id; surname = s; name = n; lastname = l; active = true; } int get_id() const { return reader_id; } bool is_active() const { return active; } };