Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. class ISBN {
  6. public:
  7.     short n[3];
  8.     short x;
  9.     char ch_x;
  10.     ISBN() {
  11.         n[0] = NULL; n[1] = NULL; n[2] = NULL; x = NULL;
  12.     }
  13.     ISBN(short n0, short n1, short n2, short x1)
  14.     {
  15.         if (n0 < 10000 && n1 < 10000 && n2 < 10000 && x1 < 10) {
  16.             n[0] = n0; n[1] = n1; n[2] = n2; x = x1; //ch_x = NULL;
  17.         }
  18.         else cerr << "Something is wrong!";
  19.     }
  20.     ISBN(short n0, short n1, short n2, char x1)
  21.     {
  22.         if (n0 < 10000 && n1 < 10000 && n2 < 10000 && x1 <= 'z') {
  23.             n[0] = n0; n[1] = n1; n[2] = n2; ch_x = x1; // x = NULL;
  24.         }
  25.         else cerr << "Something is wrong!";
  26.     }
  27.        
  28. };
  29.  
  30. class Date {
  31. public:
  32.     enum Month {
  33.         jan = 1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec
  34.     };
  35.     Date()
  36.         :y(2001), m(jan), d(1) { };
  37.     Date(int y, Month m, int d)
  38.         :y(y), m(m), d(d) { };
  39.     Month int_to_month(int x)
  40.     {
  41.         while (x < jan || dec < x);
  42.         { cerr << "неправильный месяц, введите новый: "; cin >> x; }
  43.         return Month(x);
  44.     }
  45. //protected:
  46.     int y;    
  47.     Month m;    
  48.     int d;
  49. };
  50.  
  51. /*
  52. Month Date::Month int_to_month(int x)
  53. {
  54.     if (x < jan || dec < x);
  55.     cerr << "неправильныймесяц";    
  56.     return Month(x);
  57. }
  58. */
  59.  
  60. class Patron {
  61. public:
  62.     string username() const { return Username; }
  63.     int number() const { return num; }
  64.     double vznos() const { return vzn; }
  65.     void set_vznos(Patron &p, double vznos) {
  66.         p.vzn = vznos;
  67.     }
  68.     bool check_vznos(const Patron& p) const;
  69. private:
  70.     string Username;
  71.     int num;
  72.     double vzn = 0;
  73.  
  74. };
  75.  
  76. bool Patron::check_vznos(const Patron& p) const
  77. {
  78.     if (p.vznos() != 0)
  79.         return false;
  80.    
  81.     return true;
  82. }
  83.  
  84. class Book {
  85. public:
  86.     enum Genre {
  87.         Fantastic = 1, Prose, Periodic, Biography, Kid
  88.     };
  89.     ISBN code;
  90.     string bookname;
  91.     Genre genre;
  92.     string Surname;
  93.     Date copyright;
  94.     bool on_hands;
  95.  
  96.     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)
  97.     {
  98.         code.n[0] = n0; code.n[1] = n1; code.n[2] = n2; code.x = x;
  99.         bookname = book_name;
  100.         genre = g;
  101.         Surname = Sur_name;
  102.         copyright.y = year; copyright.m = Date::int_to_month(month); copyright.d = day;
  103.         on_hands = given;
  104.     };
  105.     bool is_given(const Book& book) const;
  106. };
  107.  
  108. bool Book::is_given(const Book &book) const
  109. {
  110.     return book.on_hands;
  111. }
  112.  
  113. class Library {
  114.     struct Transaction {
  115.         Book Book;
  116.         Patron Patron;
  117.         Date Date;
  118.     };
  119.     vector<Book> Lib_Books;
  120.     vector<Patron> Patrons;
  121.     vector<Transaction> Transactions;
  122.     void add_book(Library& Lib, string bookname)
  123.     {
  124.         Lib.Lib_Books.push_back(bookname);
  125.     }
  126.  
  127. };
  128.  
  129. bool operator==(const Book& book1, const Book& book2)
  130. {
  131.     if (book1.code.n[0] == book2.code.n[0]
  132.         && book1.code.n[1] == book2.code.n[1]
  133.         && book1.code.n[2] == book2.code.n[2]
  134.         && book1.code.x == book2.code.x)
  135.         return true;
  136.    
  137.     return false;
  138. }
  139.  
  140. bool operator!=(Book& book1, Book& book2)
  141. {
  142.     return !(book1 == book2);
  143. }
  144.  
  145. /*
  146. ostream& operator<<(ostream& os, Book& book.code)
  147. {
  148.  
  149. }
  150. */
  151.  
  152. ostream& operator<<(ostream& os, const Book& book)
  153. {
  154.     os << "Book name: " << book.bookname << "Author: " << book.Surname << "ISBN: " << book.code.n[0] << '-' << book.code.n[1] << '-' << book.code.n[2] << '-' << book.code.x;
  155.     return os;
  156. }
  157.  
  158.  
  159. int main()
  160. {
  161.  
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement