from book import Book
class LibrarySystem:
def __init__(self):
self.menu = “””
Please look at below options
1. Add book
2. List all books
3. Find book by name
4. Find book by id
5. List all old books
Enter your selection. Enter ‘quit’ to exit: “””
self.title_to_book = {}
self.id_to_book = {}
def add_book(self):
print(“\nADD NEW BOOK”)
title = input(“What is the title? “)
author = input(“Who is the author? “)
publish_year = input(“When was it published? “)
book_id = input(“Enter book id: “)
book = Book(title, author, publish_year, book_id)
self.title_to_book[title] = book
self.id_to_book[book_id] = book
“””
for all methods which print book info; choose whether to print each attribute or make a method inside the book class
“””
“””
list_all_books_using_dictionary
“””
def list_all_books_using_dictionary(self):
print(“\nLIST ALL BOOKS”)
# loop through each book object using ANY of our dictionaries
for book in self.title_to_book.values():
pass
“””
list_all_old_books
only print books whose publish_year is less than 2000
(when should you turn the publish year to an integer?)
“””
“””
find_book_using_id
(use id_to_book dictionary attribute)
“””
“””
find_book_using_title
(use title_to_book dictionary attribute)
“””
def application_loop(self):
while True:
selection = input(self.menu)
if selection == “quit”:
print(“Thank you for using the Libray System.”)
break
if selection == “1”:
self.add_book()
s = LibrarySystem()
s.application_loop()