Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- class ISBN {
- public:
- short n[3];
- short x;
- char ch_x;
- ISBN() {
- n[0] = NULL; n[1] = NULL; n[2] = NULL; x = NULL;
- }
- ISBN(short n0, short n1, short n2, short x1)
- {
- if (n0 < 10000 && n1 < 10000 && n2 < 10000 && x1 < 10) {
- n[0] = n0; n[1] = n1; n[2] = n2; x = x1; //ch_x = NULL;
- }
- else cerr << "Something is wrong!";
- }
- ISBN(short n0, short n1, short n2, char x1)
- {
- if (n0 < 10000 && n1 < 10000 && n2 < 10000 && x1 <= 'z') {
- n[0] = n0; n[1] = n1; n[2] = n2; ch_x = x1; // x = NULL;
- }
- else cerr << "Something is wrong!";
- }
- };
- class Date {
- public:
- enum Month {
- jan = 1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec
- };
- Date()
- :y(2001), m(jan), d(1) { };
- Date(int y, Month m, int d)
- :y(y), m(m), d(d) { };
- Month int_to_month(int x)
- {
- while (x < jan || dec < x);
- { cerr << "неправильный месяц, введите новый: "; cin >> x; }
- return Month(x);
- }
- //protected:
- int y;
- Month m;
- int d;
- };
- /*
- Month Date::Month int_to_month(int x)
- {
- if (x < jan || dec < x);
- cerr << "неправильныймесяц";
- return Month(x);
- }
- */
- class Patron {
- public:
- string username() const { return Username; }
- int number() const { return num; }
- double vznos() const { return vzn; }
- void set_vznos(Patron &p, double vznos) {
- p.vzn = vznos;
- }
- bool check_vznos(const Patron& p) const;
- private:
- string Username;
- int num;
- double vzn = 0;
- };
- bool Patron::check_vznos(const Patron& p) const
- {
- if (p.vznos() != 0)
- return false;
- return true;
- }
- class Book {
- public:
- enum Genre {
- Fantastic = 1, Prose, Periodic, Biography, Kid
- };
- ISBN code;
- string bookname;
- Genre genre;
- string Surname;
- Date copyright;
- bool on_hands;
- Book(short n0, short n1, short n2, short x, string book_name, Genre g, string Sur_name, int year, int month, int day, bool given)
- {
- code.n[0] = n0; code.n[1] = n1; code.n[2] = n2; code.x = x;
- bookname = book_name;
- genre = g;
- Surname = Sur_name;
- copyright.y = year; copyright.m = Date::int_to_month(month); copyright.d = day;
- on_hands = given;
- };
- bool is_given(const Book& book) const;
- };
- bool Book::is_given(const Book &book) const
- {
- return book.on_hands;
- }
- class Library {
- struct Transaction {
- Book Book;
- Patron Patron;
- Date Date;
- };
- vector<Book> Lib_Books;
- vector<Patron> Patrons;
- vector<Transaction> Transactions;
- void add_book(Library& Lib, string bookname)
- {
- Lib.Lib_Books.push_back(bookname);
- }
- };
- bool operator==(const Book& book1, const Book& book2)
- {
- if (book1.code.n[0] == book2.code.n[0]
- && book1.code.n[1] == book2.code.n[1]
- && book1.code.n[2] == book2.code.n[2]
- && book1.code.x == book2.code.x)
- return true;
- return false;
- }
- bool operator!=(Book& book1, Book& book2)
- {
- return !(book1 == book2);
- }
- /*
- ostream& operator<<(ostream& os, Book& book.code)
- {
- }
- */
- ostream& operator<<(ostream& os, const Book& book)
- {
- os << "Book name: " << book.bookname << "Author: " << book.Surname << "ISBN: " << book.code.n[0] << '-' << book.code.n[1] << '-' << book.code.n[2] << '-' << book.code.x;
- return os;
- }
- int main()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement