Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Book:
- def __init__(self, title, author, ISBN, status):
- self.title = title
- self.author = author
- self.ISBN = ISBN
- self._status = status
- def __repr__(self):
- print(self.title)
- print(self.author)
- print(self.ISBN)
- print(self._status)
- def getTitle(self):
- return self.title
- def getStatus(self):
- return self._status
- def setStatus(self, check):
- self._status = check
- ################################################################
- class User:
- def __init__(self, name, ID, borList):
- self.name = name
- self.ID = ID
- self.borlist = borList
- def __repr__(self):
- print(self.name)
- print(self.ID)
- print(self.borlist)
- def borrowBookByTitle (self, libaryObj, bookTitle):
- booktoborrow = libaryObj.SearchBook(bookTitle)
- if booktoborrow.getStatus() == True:
- self.borlist.append(booktoborrow)
- booktoborrow.setStatus(False)
- else:
- print("This Book is unvaliable")
- ############################################################
- class Library:
- def __init__(self):
- self.users = []
- self.books = []
- def AddUser(self, obj1):
- self.users.append(obj1)
- def AddBook(self, obj1):
- self.books.append(obj1)
- def SearchBook (self, BookName):
- for bookobj in self.books:
- if bookobj.getTitle() == BookName:
- return bookobj
- return Book("", "", "", False)
- ################################################################################33
- MyLibrary = Library()
- MyLibrary.AddUser(User("Ahmed", "123", []))
- MyLibrary.AddUser(User("Mohamed", "1230", []))
- MyLibrary.AddBook(Book("C++", "abc", "123451", True))
- MyLibrary.users[0].borrowBookByTitle(MyLibrary, "Python")
Add Comment
Please, Sign In to add comment