-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoops-library
More file actions
73 lines (56 loc) · 1.88 KB
/
oops-library
File metadata and controls
73 lines (56 loc) · 1.88 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
73
#Python Mini Project #1 - OOPS Library
class Library:
def _init_(self,list,name):
self.bookList = list
self.libraryName = name
self.lendDict = {}
def displayBook(self):
print (f"We have following books in our library : {self.libraryName}")
for book in self.bookList:
print (book)
def lendBook(self,user,book):
if book not in self.lendDict.keys():
self.lendDict.update({book:user})
print ("Lender-book database has been updated successfully! You can take the book now")
else:
print (f"Book is already being used by {self.lendDict[book]}")
def addBook(self,book):
self.bookList.append(book)
print ("Book has been added successfully!")
def returnBook(self,book):
self.lendDict.pop(book)
if _name_ == '_main_':
prajju = Library (['Python','Java','C++','Django','HTML','CSS','Bootstrap'], 'Perfect')
while True :
print (f"Welcome to the {prajju.libraryName} library")
print ("Please Enter Your Choice : \n")
print ("1. Display Book")
print ("2.Lend a Book")
print ("3. Add a Book")
print ("4. Return a Book \n")
userChoice = input()
if (userChoice == '1'):
prajju.displayBook()
elif (userChoice == '2'):
book = input("Enter the book name you want : \t")
user = input("Enter your name : \t")
prajju.lendBook(user,book)
elif (userChoice == '3'):
book = input("Enter the book you want to add :\t")
prajju.addBook(book)
elif (userChoice == '4'):
book = input("Enter the book you want to return : \t")
print ("Your book has been returned successfully!")
prajju.returnBook(book)
else :
print ("Please choose a valid options")
print ("Press q to Quite and c to Continue")
userChoice2 = ""
while (userChoice2 != "q" and userChoice2 != "c"):
userChoice2 = input()
if userChoice2 == "c":
continue
elif userChoice2 == "q":
exit()
else:
print ("Please enter valid options")