Advertisement
Guest User

Untitled

a guest
Oct 17th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 24.19 KB | None | 0 0
  1. import pymysql
  2. import random
  3.  
  4. db = pymysql.connect("localhost", "root", "Hero2of1war", "library_system")
  5. cursor = db.cursor()
  6.  
  7.  
  8. class Library(object):
  9.     def __init__(self):
  10.         super(Library, self).__init__()
  11.  
  12.         self.number_of_library = ''  # library_number
  13.         self.street = ''
  14.         self.phone_number = 0
  15.         self.books = []
  16.         self.visitors = []
  17.         self.history = []
  18.         self.authors = []
  19.  
  20.     def add_book(self, book):
  21.         # not_found = True
  22.         # for i in self.books:
  23.         #     if i.name == book.name and i.author == book.author:
  24.         #         not_found = False
  25.         #         break
  26.         # if not_found:
  27.         #     self.books.append(book)
  28.         # else:
  29.         #     print('Book exist!')
  30.  
  31.         for i in self.books:
  32.             if i.name == book.name and i.author == book.author:
  33.                 print('Book exist!')
  34.                 break
  35.         else:
  36.             self.books.append(book)
  37.  
  38.     def delete_book(self, name, author):
  39.         book = False
  40.         for i in lib.books:
  41.             if i.name == name and i.author == author:
  42.                 self.books.remove(i)
  43.                 return True
  44.         if book == False:
  45.             print('This book not exist')
  46.             return False
  47.  
  48.     def search_book(self, book):
  49.         for i in self.books:
  50.             if i.name == book:
  51.                 return i
  52.  
  53.     def add_visitor(self, visitor):
  54.         found = False
  55.         for i in self.visitors:
  56.             print(i.name, i.last_name, i.number)
  57.             print(visitor.name, visitor.last_name, visitor.number)
  58.             if i.name == visitor.name and i.last_name == visitor.last_name and i.number == visitor.number:
  59.                 found = True
  60.         if found == False:
  61.             self.visitors.append(visitor)
  62.         else:
  63.             print('Visitor exist!')
  64.             return True
  65.  
  66.     def remove_visitor(self, name, last_name, number):
  67.         remove = False
  68.         for i in lib.visitors:
  69.             if i.name == name and i.last_name == last_name and i.number == number:
  70.                 lib.visitors.remove(i)
  71.                 return True
  72.         if remove == False:
  73.             print('Can not delete!')
  74.             return False
  75.  
  76.     def write_book_visitor(self, write, book, data):
  77.         book_in_visitor = BookInVisitor(write.name, write.last_name, book.name, book.author, data)
  78.         book_in_visitor.remove_of_data = 'None'
  79.  
  80.         self.history.append(book_in_visitor)
  81.  
  82.     def print_history(self):
  83.         for i in self.history:
  84.             print(i.visitor_name + ' take', i.book_name)
  85.  
  86.     def edit_book(self, old_name, new_name):
  87.         for i in lib.books:
  88.             if i.name == old_name:
  89.                 i.name = new_name
  90.  
  91.     def edit_visitors(self, old_name, old_last_name, old_number, new_name, new_last_name, new_number):
  92.         for i in lib.visitors:
  93.             if i.name == old_name and i.last_name == old_last_name and i.number == old_number:
  94.                 i.name = new_name
  95.                 i.last_name = new_last_name
  96.                 i.number = new_number
  97.  
  98.     def user_exist(self, old_name, old_last_name, old_number):
  99.         not_exist = False
  100.         for i in lib.visitors:
  101.             if i.name == old_name and i.last_name == old_last_name and i.number == old_number:
  102.                 return True
  103.         if not_exist == False:
  104.             print('Not exist')
  105.             return False
  106.  
  107.     def find_book_by_name(self, name, author):
  108.         for i in lib.books:
  109.             if i.name == name and i.author == author:
  110.                 return i
  111.                 # return None
  112.  
  113.     def find_visitor_by_name(self, name, last_name):
  114.         for i in lib.visitors:
  115.             if i.name == name and i.last_name == last_name:
  116.                 return i
  117.                 # return None
  118.  
  119.     # add_return_date
  120.     def add_data_of_remove(self, name, last_name, book, author, remove_date):
  121.         for i in lib.history:
  122.             if i.visitor_name == name and i.visitor_last_name == last_name and i.book_name == book and i.book_author == author:
  123.                 i.remove_of_data = remove_date
  124.  
  125.     def initialize_database(self):
  126.         cursor.execute("INSERT INTO gender (id, name) VALUES (NULL, 'male')")
  127.         cursor.execute("INSERT INTO gender (id, name) VALUES (NULL, 'female')")
  128.         db.commit()
  129.         # cursor.execute("SELECT name FROM gender")
  130.         # name_gender = cursor.fetchall()
  131.  
  132.  
  133. class Book(object):
  134.     def __init__(self, id, name, author, date, count='', available_count=''):
  135.         super(Book, self).__init__()
  136.  
  137.         self.id = id
  138.         self.name = name
  139.         self.author = author
  140.         self.date = date
  141.         self.count = count
  142.         self.available_count = available_count
  143.  
  144.     def save(self):
  145.         cursor.execute(
  146.             "INSERT INTO book (id, name, date, count, available_count) VALUES (NULL, '{0}', '{1}', {2}, {3})".format(
  147.                 self.name, self.date, self.count, self.available_count))
  148.  
  149.  
  150. class Visitor(object):
  151.     def __init__(self, id, name, last_name, birth_date, number, gender):
  152.         super(Visitor, self).__init__()
  153.  
  154.         self.id = id
  155.         self.name = name
  156.         self.last_name = last_name
  157.         self.birth_date = birth_date
  158.         self.number = number
  159.         self.gender = gender
  160.  
  161.     def save(self):
  162.         cursor.execute(
  163.             "INSERT INTO visitor (id, name, last_name, birth_date, number, gender_id) VALUES (NULL, '{0}','{1}','{2}','{3}','{4}')".format(
  164.                 self.name, self.last_name, self.birth_date, self.number, self.gender))
  165.  
  166.  
  167. class BookInVisitor(object):
  168.     def __init__(self, visitor_name, visitor_last_name, book_name, book_author, data_of_take, remove_of_data=''):
  169.         super(BookInVisitor, self).__init__()
  170.  
  171.         self.visitor_name = visitor_name
  172.         self.visitor_last_name = visitor_last_name
  173.         self.book_name = book_name
  174.         self.book_author = book_author
  175.         self.data_of_take = data_of_take
  176.         self.remove_of_data = remove_of_data
  177.  
  178.  
  179. class Author(object):
  180.     def __init__(self, id='', name='', last_name=''):
  181.         super(Author, self).__init__()
  182.  
  183.         self.id = id
  184.         self.name = name
  185.         self.last_name = last_name
  186.  
  187.     def save(self):
  188.         cursor.execute(
  189.             "INSERT INTO author (id, name, last_name) VALUES (NULL, '{0}', '{1}')".format(self.name, self.last_name))
  190.  
  191.  
  192. class BookPerAuthor(object):
  193.     def __init__(self, book_id='', author_id=''):
  194.         super(BookPerAuthor, self).__init__()
  195.  
  196.         self.book_id = book_id
  197.         self.author_id = author_id
  198.  
  199.     def save(self):
  200.         cursor.execute(
  201.             "INSERT INTO book_has_author (book_id, author_id) VALUES ({0},{1})".format(self.book_id, self.author_id))
  202.  
  203.  
  204. # user = 'Mike'
  205. # password = '123456'
  206.  
  207. lib = Library()
  208.  
  209. # user_input = input("Enter user: ")
  210. # password_input = input("Enter password: ")
  211.  
  212. # if user == user_input and password == password_input:
  213.  
  214. cursor.execute("SELECT * FROM gender")
  215. bk = cursor.fetchall()
  216. if len(bk) == 0:
  217.     lib.initialize_database()
  218.  
  219. cursor.execute("SELECT * FROM author")
  220. au = cursor.fetchall()
  221. for author in au:
  222.     author = Author(author[0], author[1], author[2])
  223.     lib.authors.append(author)
  224.  
  225. cursor.execute("SELECT * FROM book")
  226. bk = cursor.fetchall()
  227. for book in bk:
  228.     # cursor.execute("SELECT id from book WHERE name = '{0}'".format(book[1]))
  229.     # b = cursor.fetchall()
  230.     b = book[0]
  231.     # print(b)
  232.     cursor.execute("SELECT author_id from book_has_author WHERE book_id = {}".format(b))
  233.     v = cursor.fetchall()
  234.     v = v[0][0]
  235.     # print(v)
  236.     cursor.execute("SELECT name FROM author WHERE id = {}".format(v))
  237.     na = cursor.fetchall()
  238.     na = na[0][0]
  239.     # print(na)
  240.     # print(book)
  241.     book = Book(book[0], book[1], na, book[2], book[3], book[4])
  242.     lib.books.append(book)
  243.  
  244. cursor.execute("SELECT * FROM visitor")
  245. vs = cursor.fetchall()
  246. for visitor in vs:
  247.     gender_name = visitor[5]
  248.     # print(gender_name)
  249.     cursor.execute("SELECT name FROM gender  WHERE id = {}".format(gender_name))
  250.     gender = cursor.fetchall()
  251.     gender = gender[0][0]
  252.     # print(gender)
  253.     visitor = Visitor(visitor[0], visitor[1], visitor[2], visitor[3], visitor[4], visitor[5])
  254.     lib.visitors.append(visitor)
  255.     # print(visitor)
  256.  
  257. cursor.execute("SELECT * FROM book_in_visitor")
  258. bookinvisitor = cursor.fetchall()
  259. for bkinvs in bookinvisitor:
  260.     """айді списка"""
  261.     idfirst = bkinvs[0]
  262.     # cursor.execute("SELECT taking_date FROM book_in_visitor WHERE id = {}".format(idfirst))
  263.     # takingdate = cursor.fetchall()  # takingDate, TakingDate, taking_date
  264.     # takingdate = takingdate[0][0]
  265.     takingdate = str(bkinvs[1])
  266.     # print(takingdate)
  267.     # cursor.execute("SELECT returning_date FROM book_in_visitor WHERE id = {}".format(idfirst))
  268.     # returningdate = cursor.fetchall()
  269.     # returningdate = returningdate[0][0]
  270.     returningdate = str(bkinvs[2])
  271.     # print(returningdate)
  272.     # cursor.execute("SELECT visitor_id FROM book_in_visitor WHERE id = {}".format(idfirst))
  273.     # """берем число в вісітора_айді"""
  274.     # visid = cursor.fetchall()
  275.     # visid = visid[0][0]
  276.     visid = str(bkinvs[3])
  277.     cursor.execute("SELECT name FROM visitor WHERE id = {}".format(visid))
  278.     """дістаєм імя"""
  279.     visname = cursor.fetchall()
  280.     visname = visname[0][0]
  281.     # print(visname)
  282.     cursor.execute("SELECT last_name FROM visitor WHERE id = {}".format(visid))
  283.     """дістаєм прізвище"""
  284.     vislastname = cursor.fetchall()
  285.     vislastname = vislastname[0][0]
  286.     # print(vislastname)
  287.     # cursor.execute("SELECT book_id FROM book_in_visitor WHERE id = {}".format(idfirst))
  288.     # """берем число бук_айді"""
  289.     # bookid = cursor.fetchall()
  290.     # bookid = bookid[0][0]
  291.     bookid = str(bkinvs[4])
  292.     # print(bookid)
  293.     cursor.execute("SELECT name FROM book WHERE id = {}".format(bookid))
  294.     bookname = cursor.fetchall()
  295.     bookname = bookname[0][0]
  296.     # print(bookname)
  297.     cursor.execute("SELECT author_id FROM book_has_author WHERE book_id = {}".format(bookid))
  298.     authorid = cursor.fetchall()
  299.     authorid = authorid[0][0]
  300.     # print(authorid)
  301.     cursor.execute("SELECT name FROM author WHERE id = {}".format(authorid))
  302.     authorname = cursor.fetchall()
  303.     authorname = authorname[0][0]
  304.     # print(authorname)
  305.     # cursor.execute("SELECT last_name FROM author WHERE id = {}".format(authorid))
  306.     # authorlastname = cursor.fetchall()
  307.     # authorlastname = authorlastname[0][0]
  308.     # print(authorlastname)
  309.     bookvisitor = BookInVisitor(visname, vislastname, bookname, authorname, takingdate, returningdate)
  310.     lib.history.append(bookvisitor)
  311.  
  312. # book1 = Book(None, '300 spartans', 'Zak Plahin', '2001')
  313. # lib.add_book(book1)
  314.  
  315. # visitor1 = Visitor(None, 'Oleg', 'See', '12-12-2001', '+380635887884', 'male')
  316. # lib.add_visitor(visitor1)
  317. #
  318. # visitor2 = Visitor(None, 'Chak', 'Broflovski', '09-11-2001', '+38073911112', 'male')
  319. # lib.add_visitor(visitor2)
  320.  
  321.  
  322.  
  323. while True:
  324.     number = int(input(
  325.         '1 - Show all books\n2 - Show all visitors\n3 - Add visitor\n4 - Add book\n5 - Show author\n6 - Change visitor\n7 - Write book on visitor\n8 - Add remove date\n9 - Show history\n10 - Serch book by name\n11 - Search book by author\n12 - Show books in visitor\n:'))
  326.     if number == 1:
  327.         if len(lib.books) == 0:
  328.             print('Our library has not book')
  329.         for i in lib.books:
  330.             print(str(i.id) + ' Book: ' + i.name + ', author: ' + i.author + ', date: ' + str(i.date))
  331.     elif number == 2:
  332.         if len(lib.visitors) == 0:
  333.             print('Our library has not visitors')
  334.         for i in lib.visitors:
  335.             cursor.execute(
  336.                 "SELECT name FROM gender WHERE id = '{}'".format(i.gender))  # дістав назву статі із бази данних(id)
  337.             gender = cursor.fetchall()
  338.             gender = gender[0][0]  # дістав з кортежу стать в правильному вигляді
  339.             print('ID: ' + str(i.id) + ', Name: ' + i.name + ', last name: ' + i.last_name + ', birth date: ' + str(
  340.                 i.birth_date) + ', number: ' + str(i.number) + ', gender: ' + gender)
  341.     elif number == 3:
  342.         first_name = input('Enter name: ')
  343.         first_name = first_name.capitalize()
  344.         second_name = input('Enter last_name: ')
  345.         second_name = second_name.capitalize()
  346.         birth_date = input('Enter birth date(yyyy-mm-dd): ')
  347.         number = input('Enter your number(380** *** *** *): ')
  348.         gender = input('Enter: 1-male / 2-female: ')
  349.         if gender == str(1):
  350.             cursor.execute("select name from gender where id = '{}'".format(1))
  351.             sex = cursor.fetchall()
  352.             sex = sex[0][0]
  353.             # print(sex)
  354.         elif gender == str(2):
  355.             cursor.execute("select name from gender where id = '{}'".format(2))
  356.             sex = cursor.fetchall()
  357.             sex = sex[0][0]
  358.             # print(sex)
  359.         else:
  360.             print('Error: gender_id!')
  361.             break
  362.         visit = Visitor(None, first_name, second_name, birth_date, number, gender)
  363.         if lib.add_visitor(visit) == True:
  364.             continue
  365.         visit.save()
  366.         cursor.execute("SELECT last_insert_id()")
  367.         vid = cursor.fetchall()
  368.         db.commit()
  369.         # print(vid)
  370.         visit.id = vid[0][0]
  371.         # lib.add_visitor(visit)
  372.     elif number == 4:
  373.         name_book = input('Enter book name: ')
  374.         name_book = name_book.capitalize()
  375.         author_name = input('Enter author name: ')
  376.         author_name = author_name.capitalize()
  377.         author_last_name = input('Enter author last name: ')
  378.         author_last_name = author_last_name.capitalize()
  379.         found_book = False  # тому що могла змінитись змінна found на True після перевірки автора
  380.         for book in lib.books:
  381.             if book.name == name_book:
  382.                 found_book = True
  383.                 print('This book exist')
  384.         if found_book == True:
  385.             continue
  386.         found = False
  387.         for author in lib.authors:
  388.             if author.name == author_name and author.last_name == author_last_name:
  389.                 found = True
  390.                 aid = author.id
  391.                 db.commit()
  392.         if not found:
  393.             author = Author(None, author_name, author_last_name)
  394.             author.save()
  395.             cursor.execute("Select last_insert_id()")
  396.             aid = cursor.fetchall()
  397.             aid = aid[0][0]
  398.             # print(aid)
  399.             author.id = aid
  400.             lib.authors.append(author)
  401.             db.commit()
  402.         if not found_book:
  403.             date = input('Enter date(yyyy-mm-dd): ')
  404.             count = int(input('Enter count:'))
  405.             available_count = count
  406.             # print(available_count)
  407.             # print(count)
  408.             bok = Book(None, name_book, author_name, date, count, available_count)
  409.             bok.save()
  410.             cursor.execute("SELECT last_insert_id()")
  411.             bid = cursor.fetchall()
  412.             bid = bid[0][0]
  413.             db.commit()
  414.             book_per_author = BookPerAuthor(bid, aid)
  415.             book_per_author.save()
  416.             db.commit()
  417.             bok.id = bid
  418.             lib.add_book(bok)
  419.     elif number == 5:
  420.         if len(lib.authors) == 0:
  421.             print("Author do not exist")
  422.         for i in lib.authors:
  423.             print('ID:', i.id, ',' + 'name author: ' + i.name + ', last name: ' + i.last_name)
  424.     elif number == 6:
  425.         old_name = input('Enter old name of visitor: ')
  426.         old_name = old_name.capitalize()
  427.         old_last_name = input('Enter old last name of visitor: ')
  428.         old_last_name = old_last_name.capitalize()
  429.         old_number = input('Enter old number of visitor: ')
  430.         if lib.user_exist(old_name, old_last_name, old_number) == False:
  431.             break
  432.         else:
  433.             new_name = input('Enter new name visitor: ')
  434.             new_name = new_name.capitalize()
  435.             new_last_name = input('Enter new last name visitor: ')
  436.             new_last_name = new_last_name.capitalize()
  437.             new_number = input('Enter new number visitor: ')
  438.             cursor.execute(
  439.                 "UPDATE visitor SET name = '{0}', last_name = '{1}', number = '{2}' WHERE number = '{3}'".format(
  440.                     new_name, new_last_name, new_number, old_number))
  441.             db.commit()
  442.             if new_last_name == '':
  443.                 lib.edit_visitors(old_name, old_last_name, old_number, new_name, old_last_name, new_number)
  444.             elif new_name == '':
  445.                 lib.edit_visitors(old_name, old_last_name, old_number, old_name, new_last_name, new_number)
  446.             elif new_number == '':
  447.                 lib.edit_visitors(old_name, old_last_name, old_number, new_name, new_last_name, old_number)
  448.             else:
  449.                 lib.edit_visitors(old_name, old_last_name, old_number, new_name, new_last_name, new_number)
  450.     elif number == 7:
  451.         visitor_name = input('Enter visitor name: ')
  452.         visitor_name = visitor_name.capitalize()
  453.         visitor_last_name = input('Enter visitor last name: ')
  454.         visitor_last_name = visitor_last_name.capitalize()
  455.         vis = lib.find_visitor_by_name(visitor_name, visitor_last_name)
  456.         data_take = input('Enter data take(yyyy-mm-dd): ')
  457.         if vis == None:
  458.             print('Enter again visitor')
  459.             break
  460.         else:
  461.             book_name = input('Enter book name: ')
  462.             book_name = book_name.capitalize()
  463.             book_author = input('Enter author name: ')
  464.             book_author = book_author.capitalize()
  465.             bo = lib.find_book_by_name(book_name, book_author)
  466.             if bo == None:
  467.                 print('Enter again book')
  468.                 break
  469.             else:
  470.                 cursor.execute("SELECT available_count FROM book WHERE name = '{}'".format(book_name))
  471.                 avcoif = cursor.fetchall()
  472.                 avcoif = avcoif[0][0]
  473.                 if avcoif == 0:
  474.                     print("This book is not available!")
  475.                 else:
  476.                     lib.write_book_visitor(vis, bo, data_take)
  477.                     cursor.execute(
  478.                         "SELECT id FROM visitor WHERE name = '{0}' AND last_name = '{1}'".format(visitor_name,
  479.                                                                                                  visitor_last_name))
  480.                     idvisitor = cursor.fetchall()
  481.                     idvisitor = idvisitor[0][0]
  482.                     # print(idvisitor)
  483.                     cursor.execute("SELECT id FROM book WHERE name = '{}'".format(book_name))
  484.                     idbook = cursor.fetchall()
  485.                     idbook = idbook[0][0]
  486.                     # print(idbook)
  487.                     cursor.execute(
  488.                         "INSERT INTO book_in_visitor (id, taking_date, returning_date, visitor_id, book_id) VALUES (NULL, '{0}', {1}, {2}, {3})".format(
  489.                             data_take, 'NULL', idvisitor, idbook))
  490.                     cursor.execute("SELECT available_count FROM book WHERE id = {}".format(idbook))
  491.                     avco = cursor.fetchall()
  492.                     # print(avco)
  493.                     avco = avco[0][0]
  494.                     # print(avco)
  495.                     result = int(avco) - 1
  496.                     cursor.execute("UPDATE book SET available_count = '{0}' WHERE id = {1}".format(result, idbook))
  497.                     db.commit()
  498.     elif number == 8:
  499.         name1 = input('Enter visitor name: ')
  500.         name1 = name1.capitalize()
  501.         last_na = input('Enter last_name: ')
  502.         last_na = last_na.capitalize()
  503.         if lib.find_visitor_by_name(name1, last_na) == None:
  504.             print("This visitor not exist")
  505.             break
  506.         else:
  507.             book = input('Enter book: ')
  508.             book = book.capitalize()
  509.             author = input('Enter author: ')
  510.             author = author.capitalize()
  511.             if lib.find_book_by_name(book, author) == None:
  512.                 print("This book not exist")
  513.                 break
  514.             else:
  515.                 data = input('Enter data remove(yyyy-mm-dd): ')
  516.                 cursor.execute("SELECT name FROM book")
  517.                 bookname = [row[0] for row in cursor.fetchall()]
  518.                 # print(bookname)
  519.                 cursor.execute("SELECT id FROM visitor WHERE name = '{0}' AND last_name = '{1}'".format(name1, last_na))
  520.                 mid = cursor.fetchall()
  521.                 mid = mid[0][0]
  522.                 # print(mid)
  523.                 for i in bookname:
  524.                     if i == book:
  525.                         cursor.execute(
  526.                             "UPDATE book_in_visitor SET returning_date = '{0}' WHERE visitor_id = {1}".format(data,
  527.                                                                                                               mid))
  528.                         cursor.execute("SELECT available_count FROM book WHERE name = '{}'".format(book))
  529.                         avbo = cursor.fetchall()
  530.                         avbo = avbo[0][0]
  531.                         result = int(avbo) + 1
  532.                         cursor.execute(
  533.                             "UPDATE book SET available_count = '{0}' WHERE name = '{1}'".format(result, book))
  534.                         db.commit()
  535.                         lib.add_data_of_remove(name1, last_na, book, author, data)
  536.     elif number == 9:
  537.         for i in lib.history:
  538.             print(
  539.                 i.visitor_name + ' ' + i.visitor_last_name + ' take: ' + i.book_name + ', author: ' + i.book_author + ', date: ' + str(
  540.                     i.data_of_take) + ', return: ' + str(i.remove_of_data))
  541.     elif number == 10:
  542.         i = input("Enter book name: ")
  543.         i = i.capitalize()
  544.         found = False
  545.         for book in lib.books:
  546.             if book.name == i:
  547.                 print('ID: ' + str(book.id) + ', Book: ' + book.name + ', Author: ' + book.author)
  548.                 found = True
  549.         if not found:
  550.             print("Not found")
  551.     elif number == 11:
  552.         i = input("Enter author name: ")
  553.         i = i.capitalize()
  554.         found = False
  555.         for book in lib.books:
  556.             if book.author == i:
  557.                 print('ID: ' + str(book.id) + ', Book: ' + book.name + ', Author: ' + book.author)
  558.                 found = True
  559.         if not found:
  560.             print("Not found")
  561.     elif number == 12:
  562.         name = input("Enter visitor name: ")
  563.         name = name.capitalize()
  564.         last_name = input("Enter visitor last name: ")
  565.         last_name = last_name.capitalize()
  566.         for i in lib.history:
  567.             if i.visitor_name == name and i.visitor_last_name == last_name and i.remove_of_data == 'None':
  568.                 print(
  569.                     'Name: ' + i.visitor_name + ', last name: ' + i.visitor_last_name + ', book: ' + i.book_name + ', author: ' + i.book_author + ', date:' + i.data_of_take)
  570.  
  571.                 # lib = Library()
  572.                 #
  573.                 # book1 = Book()
  574.                 # book1.name = '300 spartans'
  575.                 # book1.author = 'Zak Plahin'
  576.                 #
  577.                 # book2 = Book()
  578.                 # book2.name = 'Hello'
  579.                 # book2.author = 'Jack Frans'
  580.                 #
  581.                 # book3 = Book()
  582.                 # book3.name = 'Madame Bovary'
  583.                 # book3.author = ''
  584.                 #
  585.                 # visitor1 = Visitor()
  586.                 # visitor1.name = 'Oleg'
  587.                 # visitor1.last_name = 'See'
  588.                 #
  589.                 # visitor2 = Visitor()
  590.                 # visitor2.name = 'Victor'
  591.                 # visitor2.last_name = 'Selo'
  592.                 #
  593.                 # visitor3 = Visitor()
  594.                 # visitor3.name = 'Victor'
  595.                 # visitor3.last_name = 'Selo'
  596.                 #
  597.                 # lib.add_visitor(visitor1)
  598.                 # lib.add_visitor(visitor2)
  599.                 # lib.add_visitor(visitor3)
  600.                 # lib.add_book(book2)
  601.                 #
  602.                 # lib.write_book_visitor(visitor2, book3)
  603.                 # lib.write_book_visitor(visitor1, book1)
  604.                 # lib.print_history()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement