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 3 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 3, 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:
__init__(self, title, author, year): Initializes the title, author, and year attributes when a new Book object is created. The __status is automatically set to available.
check_out(self): 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.
return_book(self): 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.
get_info(self): 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 get_info 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: J.R.R. Tolkien
Enter the year of publication: 1937
What would you like to do with this book?
1. Check out the book
2. Return the book
3. View book information
4. Add another book
Choice: 3
Book Information:
Title: The Hobbit
Author: J.R.R. Tolkien
Year: 1937
Status: available
Would you like to add another book? (y/n): y
Enter the title of the book: 1984
Enter the author of the book: George Orwell
Enter the year of publication: 1949
What would you like to do with this book?
1. Check out the book
2. Return the book
3. View book information
4. Add another book
Choice: 1
The book '1984' has been checked out.
Would you like to add another book? (y/n): n
Your Book Collection:
Title: The Hobbit
Author: J.R.R. Tolkien
Year: 1937
Status: available
Title: 1984
Author: George Orwell
Year: 1949
Status: checked out

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 Programming Questions!