def main():
while(True):
print(f'********Library Management System*********')
print(f'1 - Add Book')
print(f'2 - Remove Book')
print(f'3 - Issue Book')
print(f'')
print(f'******************************************')
user_choice = input()
if user_choice not in ['1','2','3','4','5','6','7']:
print(f'Please enter a valid option. ')
continue
else:
user_choice = int(user_choice)
if user_choice == 1:
book = input("Please Enter The Name of The Book You Want To Add :")
elif user_choice == 2:
pass
else:
print("Not A Valid Option.")
print("Enter End to QUIT or Return for MENU page.")
while(user_choice2 != "End" and user_choice!="Return"):
user_choice2 = input()
if user_choice2 == "end":
exit()
if user_choice2 == "Return":
continue
This is my menu lay out so far and I can't use GUI so I have to do it as text-based so I have a function called add book which is
def addbook(self, name, author, pages, publise_date):
b = Book(name, author, pages, publise_date)
Catalog.Books.append(b)
Catalog.different_book_count += 1
return b
But I don't know how to make it so that if the person picked 1 in the options menu they would then be given the option to add a book to the array in another book class which would be
class Book:
def __init__(self, name, author, publish_date, pages):
self.name = name
self.author = author
self.pages = pages
self.published_date = publish_date
self.total_count = 0
self.book_item = []
def addBookItem(self, isbn, rack):
b = BookItem(self, isbn, rack)
self.book_item.append(b)
self.bookcount += 1
def printBook(self):
print(self.name, self.author)
for book_item in self.book_item:
print(book_item.isbn)
def searchBookItem(self, isbn):
for book_item in self.book_item:
if isbn.strip() == book_item.isbn:
return book_item
def removeBookItem(self, book_item):
if book_item in self.book_item:
self.book_item.remove(book_item)
self.total_count -= 1
def __repr__(self): #The __repr__ method returns the string representation of an object that is machine-readable.
return self.name + ' ' + self.author
#gives name and suthor of the book
#Implement the __repr__ method to customize the string representation of an object when repr() is called on it.
This is imported into the user code which is where the menu and 2 classes for member and library emp are but I am now stuck on as to how I put this in to my menu