Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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...

1 answer below »

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

Answered Same Day Aug 20, 2021

Solution

Neha answered on Aug 21 2021
169 Votes
class Book:
li
aryName = "DePaul Li
ary"
def __init__(self,title,author,edition=-1,checkedOut="No"):
self.title = title
self.author = autho
self.edition = edition
self.checkedOut = checkedOut

def checkOut(self):
self.checkedOut="Yes"
return(self.checkedOut)

def returnBook(self):
self.checkedOut="No"
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here