Question
15.16.2. Create More Book Objects Change the following main function to create a third book object called b3 with a title of 1984 and author
15.16.2. Create More Book Objects Change the following main function to create a third book object called b3 with a title of 1984 and author George Orwell. Print out the values using the print function in the main.
class Book: """ Represents a book object """
def __init__(self, title, author):
self.title = title self.author = author def __str__(self):
return "title: " + self.title + " author: " + self.author def get_title(self):
return self.title def get_author(self): return self.get_author def set_author(self, author):
self.author = author def set_title(self, title): self.title = title def main():
b2 = Book("A Wrinkle in Time", "M. L'Engle") print(b2) b2.set_author("Madeleine L'Engle") print(b2) b1 = Book("Goodnight Moon", "Margaret Wise Brown") print(b1) main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started