Question: Part 1 : Create a Class ( ~ 6 points ) Create a class called Book with the following instance variables: title ( string )
Part : Create a Class~ points
Create a class called Book with the following instance variables:
title stringauthor stringprice float
Add a constructor to initialize these variables.Write a method displaydetails that prints all the details of the book in a neat format.
Part : Access Control~ points
Add a private variable discount float in the Book class with a default value of Write a public method getdiscount that returns the value of discount.Write another method setdiscount to update the discount value with input validation ensuring it is between and
Part : Object Instantiation~ points
Create three objects of the Book class using different values.Call displaydetails for each object.Access and modify the discount using the getter and setter methods.
Optional BonusPart : Add Another Class
Create a class Library to manage a collection of books.Add a method addbook that takes a Book object and stores it in a list.Add a method listbooks to display all books in the library.
Deliverables:
A Python script file containing the Book and Library classes and the code to test them.
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
