Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a PYTHON program for managing media check-out/check-in with members (i.e.

ID: 3838502 • Letter: C

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:

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.

To provide general information about the media and members:

Keep track of how many books and videos are in the library and how many are checked out

Keep track of how many members are there.

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__ method for print" so that you can print the contents of an object. Names used for attributes and methods are to be meaningful and easy to understand. Display a confirmation message during check-out/check-in, 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 with 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. o 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.)

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 … “ 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( … )

Joe.CheckOut( … )

Jim.CheckOut( … ) # this should attempt to checkout the same one as Joe did

Joe.CheckIn( … )

Joe.PrintCheckedOutItems()

displayStats()

Any help will be appreciated

Explanation / Answer

class Media:
title = ""
author = ""
publisher = ""
def setAttr(self, a, b, c):
Media.title = a
Media.author = b
Media.publisher = c
def getTitle(self):
return Media.title
def getAuthor(self):
return Media.author
def getPublisher(self):
return Media.publisher

class Books(Media):
pages = ""
bookcount = 0
def __init__(self, x, y, z, w):
self.setAttr(x, y, z)
self.pages = w
Books.bookcount += 1
def __repr__(self):
return 'Total Book available = %s, Book name = %s, Book author = %s, Book Publisher = %s, Total pages =%s' % (self.bookcount, self.getTitle(), self.getAuthor(), self.getPublisher(), self.pages)
  
class Video(Media):
tracktime = ""
videocount = 0
def __init__(self, m, n, o, p):
self.setAttr(m, n, o)
self.tracktime = p
Video.videocount += 1
def __repr__(self):
return 'Total Video available = %s, Video name = %s, Video author = %s, Video Publisher = %s, Total time =%s' % (self.videocount, self.getTitle(), self.getAuthor(), self.getPublisher(), self.tracktime)
class Member:
  

book1 = Books("abc", "def", "ghi", "80")
print book1
video1 = Video("mno", "pqr", "uvw", "60")
print video1