Question: You will be provided the base class, InventoryItem, in a file you can download from Blackboard called inventory _ item.py . You will create 3

You will be provided the base class, InventoryItem, in a file you can download from Blackboard called inventory_item.py. You will create 3 subclass files for each of the item categories.
In Trish's swap shop, every item she sells has an item name, item count, unit price, and a category.
For books, she wants to be able to track the ISBN13 code. That is a 13 digit code used by barcode readers.
For games, she wants to track the UPC Code. The UPC code is a 12 digit code.
For DVDs, she wants to track the UPC Code and specify a genre for the DVD. The genre will be a string.
As the software developer working on her inventory system, you've decided on the following object-oriented design for these itemYou will create six files, one for your superclass (provided to you on Blackboard), one for each of your subclasses, and two for two different main modules:
inventory_item.py
This class is nearly identical to the one you created for Lab 11 Problem 1.
Notice that in the get_item_input() method, the user is NOT asked to enter a category. That will get filled in by the subclasses when the specific object is created.
book.py
Create a file named book.py and define a class named Book that inherits from InventoryItem. The Book class has one additional public instance variable, a string called isbn13.
Define an __init__ method that takes four default arguments, three from InventoryItem and one additional one named isbn13.
o Call the superclass __init__ method to initialize the superclass instance variables. When calling the superclass dunder init, set the category to "Book".
o Then initialize the isbn13 instance variable.
Define a get_item_input method that takes no arguments. This method will override the method in the superclass. This method will get user input to fill in all the Book objects attributes.
o You should call the superclass's get_item_input method to fill in the name, count, and cost instance variables first before writing additional code to fill in the isbn13 instance variable.
o Make sure to include data validation to ensure for isbn13 the user enters a string with 13 characters that is all digits.
Define a __str__ method that will return a string that includes this object's data. When a Book object is printed, it should appear like this:
Science Book
Count: 100, Cost: 22.95
Category: Book
ISBN: 2345234523451
Wherever possible, your program should call the super() function to access methods from the base class to avoid copying code from the base class module.
game.py
Create a file named game.py and define a class named Game that inherits from InventoryItem. The Game class has one additional public instance variables, a string called upc.
Just as you did with the Book class, override the superclass __init__, get_item_input, and __str__ methods to perform appropriate actions for this class.
o Make sure the __init__ method sets the category for this object to be "Game".
o Make sure your get_item_input method does data validation to ensure the UPC entered by the user is a string with 12 digits.
If this object is created directly, here's what it should look like:
Monopoly
Count: 50, Cost: 12.95
Category: Game
UPC: 098765432121
Wherever possible, your program should call the super() function to access methods from the base class to avoid copying code from the base class module.
dvd.py
Create a file named dvd.py and define a class named DVD that inherits from InventoryItem. The DVD class has two additional public instance variables, a string called upc and a string called genre.
Perform similar actions here as you did with the Game class. The category should be set to "DVD".
If this object is created directly, here's what it should look like:
Fifth Element
Count: 30, Cost: 6.95
Category: DVD
UPC: 098765432121
Genre: Sci Fi
To test the work you did for creating subclasses, you are going to create TWO different main programs.
Lab12P1a.py
Create a file named Lab12P1a.py. This file will be the main module that holds the main program.
In the main module, create 5 objects with the following information:
Object Type Item Name Item Count Unit Cost ISBN13 UPC Genre
Book Python Now 10022.952345234523451
Book Even More Python 1508.953456345634561
Game Uno 756.95123456789012
DVD Barbie 5012.00098765432121 Comedy
DVD The Piano 102.90321321321321 Drama
After creating these 5 objects, print the objects directly.
o In our class, "print directly" means do NOT call __str__() in the code, but just print the object, and Python will automatically call __str__() when converting the object to a string.s:
You will be provided the base class,

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!