Question: Part A: [20 pts) Write a class named Book that represents each book in a library. Each book has the following attributes: . title: the




Part A: [20 pts) Write a class named Book that represents each book in a library. Each book has the following attributes: . title: the title of the book. author: the author of the book. content: a string representing the text of the book. - The Book class should have an initializer that accepts the book's title, author, and content as arguments. - These values should be assigned to the object's respective attributes. The class should also have the following methods: read(): takes in a page number, and prints out the content of each page starting from the beginning until the given page number is reached. Each page is separated by the n' character.) str_0 : return a string describing this book in terms of its name and author (e.g.," Wuthering Heights by Emily Bronte"). Write a class named Comic Book that inherits the Book class from Part A. A ComicBook should have an additional boolean attribute is_superhero that indicates whether it is a comic about superheroes or not. The value of this attribute should be able to be set when initialized. > Part C: (20 pts] Write a class named Library Employee. Each LibraryEmployee has the following attributes: name: the name of the employee. favorites: a set of this employee's favorite Books (or Comic Books). num_coffees: an integer representing how many coffees this employee has had today. This value should begin at zero when a Library Employee is initialized. The LibraryEmployee class should have an initializer that accepts the employee's name and favorites as arguments. These values should be assigned to the object's respective attributes. Additionally, the Library Employee class should have the following methods: drink_coffee(): takes in an integer num, and increases this Library Employee's num_coffees attribute by that integer. _str_0 : return the LibraryEmployee's name. Part D: [25 pts] Write a class named Library. A library has the following attributes: name: the name of this library. employees: a list of Library Employees that work at the library. books: a dictionary that contains Books as keys. The value paired with each key is either an empty string, or a string representing the name of a person who has checked out the Book. The Library class should have an initializer that accepts employees and books as arguments. If provided, these values should be assigned to the object's respective attributes. If not provided, employees and books should begin as an empty list and dictionary, respectively. The value for the name attribute is always provided. The class should also have the following methods: hire_employee(): takes in a new Library Employee, and adds it to this library's list of employees. add_book(): takes in a new Book, and adds it to this library's books (unless the library already has this book). If the library already has the book, print out the name of the library followed by "already has this book!. - check_out_book(): takes in a Book and a person's name. If this book is in the dictionary of books, change the value at that key in the books dictionary to the person's name. Otherwise, print out Sorry, we don't have followed by the name of the book and a period. return_book(): takes in a Book. If this book is in the dictionary of books, change the value at that key in the books dictionary to an empty string. Otherwise, print out Sorry, wrong library.". str_0 : return the name of the library
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
