Question: Create a python program for managing media check-out/check-in with members (i.e. a library) There are two types of Media objects - Books and Videos :
Create a python program for managing media check-out/check-in with members (i.e. a library) There are two types of Media objects - Books and Videos: Books have title, author, publisher, and number of pages. Videos have title, author, publisher, and running time.
There is a Members object: Members have name and can checkOut() and checkIn() books and videos. If a book or a video is already checked out, then it cannot be checked out again until it is checked back in. Store a list of checked out items for a member and create a method to display it. Requirements: You are to create object oriented code and keep all attributes within the objects. Your code is to use demonstrate the concept of inheritance, method overriding. You are to implement the "__repr__() or__str__()" for print() so that you can print out the contents of the object. Names used for attributes and methods are to be meaningful and easy to understand. Display a confirmation message during check-out/check-in by showing the name of the member and the information of the media. A member shall only be allowed to check out 2 items at once. Hints: Media is a superclass of Books and Videos - There is no need to create a library class. All common attributes and methods should be placed in the superclass. Anything specific to the subclasses should be stored and implemented in the subclasses. Consider what information should be stored in instance attributes and what in class attributes. Members is a standalone class for keeping information about the member. ? You need to implement methods to enable the member to interact with books and videos by passing the instance object as argument (refer to class example.) - Follow good programming practices and make sure that your code includes plenty of comments. - Refrain from reusing the same name for attributes/variables throughout the code for different purposes as this will get confusing and makes the code hard to read. To test your code, you must: Create instances of books, videos, and members. Call the checkOut and checkIn methods on each member. Call the printCheckOutItems method to display all items checked out by a member. Call the checkOut method on a book/video that is already checked out by another member and verify that a message is displayed The book/video is already checked out by member(name) Call the displayStats method to display records of o The total number of books, and books checked out o The total number of videos, and videos checked out o The total number of members Below an example for reference, you can create more test cases as needed. book1=Book( ) # creates an instance for a book book2=Book( ) # creates an instance for a book Joe=Members("Joe Smith") # creates an instance for a member Jim=Members("Jim Stuart") # creates an instance for a member Joe.checkOut( ) video1=Video( ) # creates an instance for a video Joe.checkOut( ) Jim.checkOut( ) # should attempt to check out the same one as Joe did Joe.checkIn( ) Joe.printCheckedOutItems() displayStats() Simple exam would be like this:
class paper(object): def __init__(self): self.sheet ="" def addText(self, text): self.sheet += text # sheet = sheet + text def __repr__(self): return "{} {}".format(40*"*",self.sheet) # a student can read or write to a sheet of paper class student(object): def __init__(self, name): self.name=name def write(self,a_paper,text): a_paper.addText(self.name+"'s message: "+text+" ") print(self.name+" just wrote something ") def read(self,a_page): print(self.name+" is reading ") return a_page adam=student("Adam") eve=student("Eve") note1=paper() note2=paper() adam.write(note1,"Hello there, how are you ?") print(eve.read(note1)) eve.write(note1,"I'm fine, how about you ?") print(adam.read(note1)) sam=student("Sam") print(sam.read(note1)) Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
