def main(): """ creates a list and fills it with Item objects. Creates a Library object, a catalogue object and a LibraryItemGenerator object. While loop runs until user inputs 0, other inputs demonstrate the possible functions within library and catalogue modules. :return: """ item_list = [ item.Book("Lord of the Rings", "1023.2323", "JRR Tolkien", 1), item.Book("Game of Thrones", "1032.1212", "GRR Martin", 1), item.Book("Harry Potter", "1111.2222", "JK Rowling", 1), item.DVD("Pursuit of Happiness", "April 12, 1974", "NTSC", 1, "12121"), item.Journal("National Geographic", 10, "Science", 1, "51232"), item.Book("Game of Thrones", "1033", "GRR Martin", 1) ] biblioteca = Library(item_list) catalogue_ = catalogue.Catalogue(item_list) generator_ = catalogue.LibraryItemGenerator(item_list) choice = 1 while choice != 0: print("Welcome to Biblioteca self-service") print("If you would like to find a book, press 1") print("If you would like to request an item be removed press 2") print("If you would like to check out an item press 3") print("If you would like to return an item press 4") print("If you would like to add an item press 5") print("If you would like to browse the full catalogue press 6") print("If you would like to end self-service press 0") choice = int(input("what would you like to do? ")) if choice == 1: title = input("Enter the title of the book you are looking for: ") if isinstance(title, str): catalogue_.find_item(title) else: return "Sorry, that is an invalid title" if choice == 2: call_number = input("Enter the call number for the book: ") if isinstance(call_number, str): catalogue_.remove_item(call_number) else: return "That is an invalid call number" if choice == 3: call_number = input("Enter the call number for the book: ") if isinstance(call_number, str): biblioteca.check_out(call_number) else: return "That is an invalid call number" if choice == 4: call_number = input("Enter the call number for the book: ") if isinstance(call_number, str): biblioteca.return_item(call_number) else: return "that is an invalid call number" if choice == 5: generator_.generate_item(item_list) if choice == 6: display_available_books(item_list)
def create_journal(self, title, ident): """ Create a new 'journal' object and pass to the library controller to add to its item list :param title: title of the journal to be created :param ident: id of the journal to be created :return: no return """ new_journal = item.Journal(title, ident)
def generate_item(self, item_list): print(f"what kind of item would you like to make?\n ") print(f"1. Book") print(f"2. DVD") print(f"3. Journal") choice = int(input("Your selection? ")) if choice == 1: print("Please enter the Title, Call Number, and Author") item_ = item.Book("", 0, "", 0) item_.title = input("Title?") item_.call_number = input("Call Number?") item_.author = input("Author?") item_.num_copies = 1 self.item_list.append(item_) if choice == 2: print( "Please enter the title, call number, release_date, and region_code" ) item_ = item.DVD("", 0, "", 0, 0) item_.title = input("Title?") item_.call_number = input("call number?") item_.release_date = input("release date?") item_.region_code = input("region code?") item_.num_copies = 1 self.item_list.append(item_) if choice == 3: print("Please enter the title, call_number, issue, and publisher") item_ = item.Journal("", 0, "", 0, 0) item_.title = input("Title?") item_.call_number = input("call number?") item_.issue = input("issue?") item_.publisher = input("publisher?") item_.num_copies = 1 self.item_list.append(item_) else: print("Sorry, that's an invalid option")
def create_journal(self, name, id): """Adds a journal to item list.""" theitem = item.Journal(id, name) self.lib_mgr.add_item(theitem)