-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path27.07 Library with Utility.py
More file actions
143 lines (127 loc) · 3.99 KB
/
27.07 Library with Utility.py
File metadata and controls
143 lines (127 loc) · 3.99 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import datetime
import random
class LibraryItem:
def __init__(self, t,a,i):
self.__Title = t
self.__AuthorArtist = a
self.__ItemID = i
self.__OnLoan = False
self.__DueDate = datetime.date.today()
self.__BorrowerID = 0
def GetTitle(self):
return (self.__Title)
def GetAuthorArtist(self):
return (self.__AuthorArtist)
def GetItemID(self):
return (self.__ItemID)
def Borrow(self, bid):
self.__BorrowerID = bid
self.__OnLoan = True
self.__DueDate = datetime.date.today()+7
def Return(self):
self.__BorrowerID = 0
self.__OnLoan = False
self.__DueDate = None
#lend book
def ShowDetail(self):
print("ID: ", self.GetItemID())
print("Title: ", self.GetTitle())
print("Author: ", self.__AuthorArtist)
class Book(LibraryItem):
def __init__(self, t, a, i):
LibraryItem.__init__(self, t, a, i)
self.__IsRequested = False
self.__RequestedBy = 0
def ShowDetail(self):
LibraryItem.ShowDetail(self)
#print("is requested: ", self.__IsRequested)
def SetIsRequested(self, bid):
self.__RequestedBy = bid
class CD(LibraryItem):
def __init__(self, t, a, i):
LibraryItem.__init__(self, t, a, i)
self.__Genre = ""
def GetGenre(self):
return (self.__Genre)
def SetGenre(self, g):
self.__Genre = g
class Borrower:
def __init__(self, n, e):
self.__BorrowerName = n
self.__Email = e
self.__BorrowerID = random.randint(100,200)
self.__ItemsOnLoan = 0
def GetBorrowerName(self):
return self.__BorrowerName
def GetEmail(self):
return self.__Email
def GetBorrowerID(self):
return self.__BorrowerID
def GetItemsOnLoan(self):
return self.__ItemsOnLoan
def UpdateItemsOnLoan(self):
self.__ItemsOnLoan += 1
def PrintDetail(self):
print("ID: ", self.GetBorrowerID())
print("Name: ", self.GetBorrowerName())
print("Email: ", self.GetEmail())
print(f"There are {self.__ItemsOnLoan} items borrowed.")
def Menu():
choice = 't'
while choice not in (0,1,2,3,4,5,6,7,8,9):
print("1 – Add a new borrower")
print("2 – Add a new book")
print("3 – Add a new CD")
print("4 – Borrow a book")
print("5 – Return a book")
print("6 – Borrow a CD")
print("7 – Return a CD")
print("8 – Request book")
print("9 – Print all details")
print("0 – Exit program")
try:
choice = int(input("Enter your menu choice: "))
except ValueError:
choice = 'a'
return choice
def main():
Borrowers = []
Books = []
CDs = []
choice=Menu()
while choice != 0:
if choice==1:
name = input("Enter name of borrower ")
email = input("Enter email of borrower ")
Borrowers.append(Borrower(name,email))
elif choice ==2:
pass
elif choice==3:
pass
elif choice==4:
pass
elif choice==5:
pass
elif choice==6:
pass
elif choice==7:
pass
elif choice==8:
pass
elif choice==9:
print(Borrowers[0].GetBorrowerName())
choice = Menu()
main()
##Title=input("Enter book title: ")
##Author = input("Enter book author: ")
##ItemID = random.randint(10000, 50000)
## BookArray = [None for x in range(10)]
#BookArray[0] = Book(Title, Author, ItemID)
#BookArray[0].ShowDetail()
## ThisBook = Book("Harry Potter and Deathly Hallows", "J. K. Rowling", 453)
##
## ThisBorrower = Borrower("faheem", "faheem@gamil.com")
## ThisBook.ShowDetail()
## ThisBorrower.PrintDetail()
##
##