Library System

 # creat a library class

# display book
# lend book (who own the book if not present)
# add book
# return book
# Suman Library = Library(listofbooks, library_name)
# dictionary (book-nameofperson)


class Library():
list_of_book = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
lender = {'blank': 'blank'}

def booklist(cls):
print(cls.list_of_book)
print(f"THE ABOUVE BOOK BYDEFAULT REGISTER IN YOUR LIBRARY")
i = 0
while i<10:
con = input("PRESS 'Y' TO ADD MORE BOOK IN REGISTER\n PRESS 'N' TO GOTHROUGH WITH DEFAULT BOOK: ")
if con == 'Y':
book_list = input("Enter the book name to add in Library: ")
cls.list_of_book.append(book_list)
i += 1
if con == 'N':
break

def display(cls):
return print(cls.list_of_book)

def lend(cls):
newlend = input("Enter your name: ")
book = input("Enter The Book Name: ")
if book in cls.list_of_book:
cls.lender.update({book:newlend})
cls.list_of_book.remove(book)
return print(cls.lender, "\nLending Sussesfull")
return print()
if book not in cls.list_of_book:
s = cls.lender.get(book)
# return print(s)
return print(f"Your book is not in stock. It is Lend to {s}")

def addbook(cls):
book_add = input("Enter The Book name to Add in Libary: ")
cls.list_of_book.append(book_add)
return print("Thank U! Your book succesfully add to the Library", cls.list_of_book)
@classmethod
def returnbook(cls):
name = input("Enter your name to return the book: ")
key_list = list(cls.lender.keys())
val_list = list(cls.lender.values())
if name in val_list:
position = val_list.index(name)
book_return = key_list[position]
cls.list_of_book.append(book_return)
return print("Thank u! Visit Again")
else:
print("U Have not lend any book! Plese Leand First")

index = ("Press D for Display Books/ "
"Press L for Lend a Book/ "
"Press A for Add a Book/ "
"Press R for Return a Book/ "
"PRESS E FOR EXIT")
print("-------------WELCOME TO THE LIBRARY SYSTEM--------------")
name = input("Enter your name to start the Library system: ")
print(f"WELCOME TO THE {name} LIBRARY SYSTEM")
s = Library()
s.booklist()
while True:
print(index)
user = (input("Please Enter your Choice: "))
fuser = user.capitalize()
if fuser == 'D':
s.display()
elif fuser == 'L':
s.lend()
elif fuser == 'A':
s.addbook()
elif fuser == 'R':
s.returnbook()
elif fuser == 'E':
exit()
else:
print("Invalide Input")

Comments

Popular posts from this blog

FACTORY DOCUMENTATION

AI ASSISTANCE (BASIC)