-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLMS.py
More file actions
72 lines (63 loc) · 2.36 KB
/
LMS.py
File metadata and controls
72 lines (63 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
class Library:
def __init__(self, listOfBooks):
self.books = listOfBooks
def displayBooks(self):
print("The available books in the library are: ")
for book in self.books:
print(" *" + book)
def borrowBooks(self, bookName):
if bookName in self.books:
print(f"You have borrowed the {bookName}. Please keep it safe...")
self.books.remove(bookName)
return True
else:
print(f"Sorry! {bookName} book is either not available or already been issued to someone else...")
return False
def returnBook(self, bookName):
self.books.append(bookName)
print("Thanks for returning it. Hope you enjoy reading it")
def addBook(self, bookName):
self.books.append(bookName)
print("Thanks for donating the book to the library!!")
class student:
def requestBook(self):
self.book = input("Enter the name of the book: ")
return self.book
def returnBook(self):
self.book = input("Enter the name of the book you want to return: ")
return self.book
def addBook(self):
self.book = input("Enter the name of the book you want to add to the library: ")
return self.book
if __name__ == "__main__":
centralLibrary = Library(["Algorithms", "Sherlock Holmes", "Django", "HTML Notes", "Python Notes", "C++ Notes", "Java Notes"])
student = student()
msg = '''
### Welcome to the Central library of the university ###
Please Enter the option:
1. List the names of all available books
2. Request to borrow a book
3. Return a book
4. Add a book to the library
5. Exit the Library
'''
print(msg)
while(True):
wlcMsg = '''
Please Enter the option :
'''
print(wlcMsg)
a = int(input("How can I help you? : "))
if a == 1:
centralLibrary.displayBooks()
elif a == 2:
centralLibrary.borrowBooks(student.requestBook())
elif a == 3:
centralLibrary.returnBook(student.returnBook())
elif a == 4:
centralLibrary.addBook(student.addBook())
elif a == 5:
print("Thanks for using the Central Library!!")
exit()
else:
print("You entered an invalid choice.....")