Question: Description: Create a class in Python 3 named Book that has specified attributes and methods. Purpose: The purpose of this challenge is to practice creating
Description: Create a class in Python named Book that has specified attributes and methods.
Purpose: The purpose of this challenge is to practice creating and working with a class, attributes, and methods in Python without introducing inheritance or subclassing.
Requirements
Write a class named Book with the following attributes and methods, and save it in a file called Book.py
Attributes:
title: A hidden attribute that stores the books title.
author: A hidden attribute that stores the books author.
year: A hidden attribute that stores the publication year.
status: A hidden attribute that stores whether the book is checked out or available. Default value is available
Methods:
initself title, author, year: Initializes the title, author, and year attributes when a new Book object is created. The status is automatically set to available
checkoutself: Sets the status attribute to checked out if the book is available. If the book is already checked out, it should return a message saying the book is not available.
returnbookself: Sets the status attribute to available if the book is checked out. If the book is already available, it should return a message saying the book is not checked out.
getinfoself: Returns a formatted string with the books title, author, year, and current status.
Book Collection Program
Create a separate Python file called bookCollection.py This program will allow the user to create and manage a collection of books.
Prompt the user to enter details about a book title author, year and create a Book object.
Ask the user if they want to:
Check out the book.
Return the book.
View the books information.
Add another book to the collection.
Store each Book object in a list.
After the user is done adding books, loop through the list and display information for all books using the getinfo method.
Sample Output
Welcome to the book collection manager!
This program lets you manage your book collection.
Enter the title of the book: The Hobbit
Enter the author of the book: JRR Tolkien
Enter the year of publication:
What would you like to do with this book?
Check out the book
Return the book
View book information
Add another book
Choice:
Book Information:
Title: The Hobbit
Author: JRR Tolkien
Year:
Status: available
Would you like to add another book? yn: y
Enter the title of the book:
Enter the author of the book: George Orwell
Enter the year of publication:
What would you like to do with this book?
Check out the book
Return the book
View book information
Add another book
Choice:
The book has been checked out.
Would you like to add another book? yn: n
Your Book Collection:
Title: The Hobbit
Author: JRR Tolkien
Year:
Status: available
Title:
Author: George Orwell
Year:
Status: checked out
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
