-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path27.03 Library Item Inheritance.py
More file actions
79 lines (67 loc) · 2.28 KB
/
27.03 Library Item Inheritance.py
File metadata and controls
79 lines (67 loc) · 2.28 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
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()
def GetTitle(self):
return (self.__Title)
def GetAuthorArtist(self):
return (self.__AuthorArtist)
def GetItemID(self):
return (self.__ItemID)
#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)
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.")
##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()