Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Well let s first start by going over the inventory dictionary, see image below The item name Again, the reason we ask for category to

Well lets first start by going over the inventory dictionary, see image below The item name
Again, the reason we ask for category to be enter
Instructions:
1. You will create 3 Classes, one for each category. Refer to bullet points below on the names that you are to assign for each class.
Create a DeskSp class. You might have guess already but DeskSp is short for Desk Supplies
Create an OfficeSp class. This class is for Office Supplies.
Create a ComSp class for the Computer Accessories category.
2. Next , make sure that each one of the classes above has the following attributes
Item_name (must be defined when creating an instance)
quantity (must be defined when creating an instance)
unit_price (must be defined when creating an instance)
total (automatically created when instance is created. Is the result of quantity multiplied by unit_price )
all attributes must be protected
2. Define necessary methods for each one of the three classes, should include the following
__repr__ method . This method should return a string that consists of the following (item_name , quantity, unit_price and total ). Note that it should also allocate 20 spaces for item_name and 12 spaces for the remaining attributes
a set_total method that will be used to assign a value to the total attribute. This method is to be triggers when an instance is created in order to automatically calculate the total for each item.
getter method for each attribute. each method is to return the value that is reference in the attribute it was created for
setter method for the quantity and unit_price attributes.
After having created the classes, lets move on to what the program should do.
3. Add a create_instance() function to the M4Pro program or M6Pro, whichever you want to build on.
This function should be passed the inventory dictionary.
It is to iterate over the dictionary and verify the category.
o If the category is Desk Supplies, create a DeskSp instance for each item under Desk Supplies. Remember, total should be automatically calculated by the set_total() method for each item.
o If the category is Office Supplies, create a OfficeSp instance for each item under Office Supplies. Remember, total should be automatically calculated by the set_total() method for each item.
o If the category is Computer Accessories, create a ComSp instance for each item under Computer Accessories. Remember, total should be automatically calculated by the set_total() method for each item.
the function is to return Three lists, one for each category . Remember each list will reference the instances that were created for each class.
4. Add write_instance() function that does the following:
this function should be passed a list(ONE list) of class objects.
it iterates over the list of objects then writes the following information for each object/instance
o item name
o quantity
o unit_price
o total
object information is to be retrieved using the getter methods defined for category.
the created csv file should have the following header row (Item Name, Quantity, Unit Price , Total)
The csv file should be assigned the category name
How will the program work?
4. When program is executed, the following menu will be displayed (Notice its exactly the same as what was requested in M6Pro and M4Pro)
5. if 1 is entered, the following should be done:
- the program is still to display the inventory content as requested in M6Pro.
- the create_instance function should be called. ( this is the function you were requested to create in step 3 above)
- then the write_instance() function should be called.
so in this step, class instance will be created for each category AND list of instances for each category should be written to a separate csv file (so 3 csv files will be created here , one for each category)
6. if user enters 2, we want the program to work a little differently. See below for details.
Call the create_instance function here too so that instances are created. This step is necessary to ensure instances are created regardless of what menu option the user chooses first
Ask the user to enter the category name then determine which list of instances to look in.
For instance , if the user enters Desk Supplies the program should look in the list that references the DeskSp instances.
After having determined the category , iterate over list of objects and use the getter methods to retrieve and display the following.
o Item name
o Quantity
o Unit Price
Make sure the information is displayed in a tabular format (remember the linked program does that already)
7. options 3 is to be altered the same way option 2 was. Meaning a list of instances for each category/class is to be created first.
Next, ask the user to enter the following
The category of the item they are looking for
The item name
We will consider the above instead of asking for item name only in order to simplify the process. So i
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

Be familiar with the integrative servicescape model.

Answered: 1 week ago

Question

Understand the role of corporate design in communications.

Answered: 1 week ago