You are on a design team writing code for a library. Create a class calledBookwith instance variables fortitle(string),author(string), andedition(int), andcheckedOut(boolean). Also include aclassvariable calledlibraryNameand set its value to 'DePaul Library' (or to some other, perhaps cooler sounding name of your choosing).
Be sure to have a constructor (including default values for all variables), a__str__method, and an__eq__method.
The constructor should set the default values oftitleandauthortounset, theeditionto -1, and thecheckedOuttoNone.
In your__eq__method, your comparison of the two strings (i.e.titleandauthor) should allow for case differences. For example, if the title of one book is 'Game of Thrones' and the title of another is 'game of thrones', they should still be considered as having the same title.
In the__str__method when you output the value of thecheckedOutinstance variable, do not outputTrueorFalse. Instead, your__str__method should output'Yes'or'No'for that particular variable. Your method should also output the name of the library (i.e. the class variable) with three dashes on either side (or some other decoration) as shown below.
Your class should have a method calledcheckOut()that sets thecheckedOutinstance variable toTrue.
You should also have a method calledreturnBook()that sets thecheckedOutinstance variable toFalse.
Here is some sample code to test your class, along with the expected output.
b1 = Book('Great Expectations','Charles Dickens',3)
b2 = Book('Canterbury Tales','Geoffry Chaucer',1,co=False)
b2.checkOut() #when we print, Checked Out? should print 'Yes'
b3 = Book('great expectations','charles dickens',3)
print(b1)
print()
print(b2) #NOTE: 'checkedOut' should indicate'Yes'
print()
print(b3)
print()
print('Comparing b1 and b3 - should be True:\t', b1==b3)
print('Comparing b2 and b3 - should be False:\t', b2==b3)
Here is the expected output:
---Library for Make Great Country of Boratistan---
Title: Great Expectations
Author: Charles Dickens
Edition: 3
Checked Out? No
---Library for Make Great Country of Boratistan---
Title: Canterbury Tales
Author: Geoffry Chaucer
Edition: 1
Checked Out?Yes
---Library for Make Great Country of Boratistan---
Title: great expectations
Author: charles dickens
Edition: 3
Checked Out? No
Comparing b1 and b3 - should be True: True
Comparing b2 and b3 - should be False: False