Repository navigation
Expand file tree
/
Copy pathassignment.py
More file actions
61 lines (50 loc) · 1.52 KB
/
Copy pathassignment.py
File metadata and controls
61 lines (50 loc) · 1.52 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
class Library:
"""docstring for """
def __init__(self, listOfBooks):
self.availableBooks = listOfBooks
def displayAvailableBooks(self):
print("Avaialable Books: ")
for book in self.availableBooks:
print(book)
def lendBook(self, requestedBook):
if requestedBook in self.availableBooks:
print("You have now borrowed book ", requestedBook)
self.availableBooks.remove(requestedBook)
def addBook(self, returnedBook):
self.availableBooks.append(returnedBook)
print("You have now returned book ", returnedBook)
print("Thank you")
class Customer:
def requestBook(self):
print("Enter the book name you would like to borrow: ")
self.book = input()
return self.book
def returnBook(self):
print("Enter the name of book you would like to return: ")
self.book = input()
return self.book
library = Library(['Think & Grow Rich', 'Who Will Cry When You Will Die', 'For One More Day'])
customer = Customer()
while True:
print("Enter 1 to display available books")
print("Enter 2 to request for book")
print("Enter 3 to return book")
print("Enter 4 for exit")
userChoice = int(input())
if userChoice is 1:
print("user choice is 1")
library.displayAvailableBooks()
elif userChoice == 2:
print("user choice is 2")
requestedBook = customer.requestBook()
library.lendBook(requestedBook)
elif userChoice == 3:
print("user choice is 3")
returnedBook = customer.returnBook()
library.addBook(returnedBook)
elif userChoice == 4:
print("user choice is 4")
quit()
else:
print("Invalid input")
quit()