Question: Q2. Write a class Book which has the following: - Instance variables: Book title Book author Year: this variable stores the year of publishing. Available:

 Q2. Write a class Book which has the following: - Instance

Q2. Write a class Book which has the following: - Instance variables: Book title Book author Year: this variable stores the year of publishing. Available: Boolean variable that indicate if the book is available or not Total number of books: this variable stores the total number of books in the library - Constructor: initializes the book title, author, and year. If the year is less than 1990 or greater than the current year, then print an error message. The constructor also increases the number of total books by 1 and set available to True. - Set and get methods for all variables. Write a test code. Create the following objects (instance) of type Book: - Title: Harry potter, author: J. K. Rolling, Year: 1997 - Title: The Da Vinci Code, author: Dan Brown, Year: 2003 - Title: Life of PI, author: Yann Martel, Year: 2001 Add all the books to an array. Then print a menu that allows users to borrow a book, or search a book by year. If the user choses to borrow a book, then only print the books that are available. Make sure to change the book availability to False if a user borrowed it. If all the books are borrowed, then, print "No books are available at the moment". Refer to the sample output in the next page

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!