Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
For this assignment you will be writing a single program that will contain three Python object-oriented
classes and methods associated with each class. The classes will model a library with its books, patrons
(library users), and check-outs (books checked out to patrons). Name your program file in the manner you
have done in previous assignments and submit it in Brightspace as usual.
If you work with another person on this program, please be sure to credit them in the comments in the
header of the program. Remember to comment your programs well and to put a header at the top of the
program with your name, the course number and section, the date, and the assignment number.
You do not have to use IPO notation for the methods you write for this assignment but put at least a one-
line header comment above each method you write. However, you should use IPO notation for any
functions you write outside the class definitions.
Problem: Define Classes Describing Books, Patrons, and Checkouts
For this problem you will be defining three classes, Book, Patron, and Checkout. For each, you will need
to define the __init__ and __str__ methods to respectively initialize objects in the classes and to print
them.
The Book class has four attributes, three of which are passed to it at instance initialization. The first three
are the author (a string), the title of the book (a string), and the number of copies that the library has (a
positive integer from 1 to 4). The fourth is the number of copies checked out, which should be set to zero
at initialization.
The Patron class has two attributes, both of which are passed to it at instance initialization. These are the
patron’s library card number (an integer) and their name (string).
The Checkout class has two attributes, both of which are passed to it at instance initialization. These are
the patron (a Patron object) and the book (which is a Book object). When a checkout object is created, the
number of copies checked out of its Book object attribute should be increased by one.
You should write a function called borrow that takes as parameters a Patron object, a Book object, and a
list of all the current Checkout objects. If a patron tries to borrow a book for which all copies are already
loaned, it should refuse to check it out. If a copy is available, then it should create a Checkout object and
add it to the list of Checkout objects. It should return the updated list of Checkout objects.
You should also write a function called library_return which takes the same parameters as borrow. It
should search the list of the current Checkout objects for a Checkout that matches the book and patron. If
it finds it, it should remove it from the list and subtract one from the number of copies checked out for
that book.