Question: PYTHON HELP: UNDERSTANDING INHERITANCE In this assignment, you will be creating an inheritance hierarchy of classes used to handle the different types of furniture items

PYTHON HELP: UNDERSTANDING INHERITANCE

PYTHON HELP: UNDERSTANDING INHERITANCE In this assignment, you will be creating an

inheritance hierarchy of classes used to handle the different types of furniture

items in a store. The class hierarchy is shown in the following

In this assignment, you will be creating an inheritance hierarchy of classes used to handle the different types of furniture items in a store. The class hierarchy is shown in the following diagram: Furniture Bed Table Specifically, 1) Add a base class called Furniture: a. Add a private attribute called _weight which represents the weight of the furniture in lbs. b. Add a constructor that takes one argument, weight in lbs. The constructor should set the private attribute called _weight. It should throw a ValueError exception saying "Weight must be positive" if the weight argument is less than or equal to 0. c. Add a public property called weight backed by _weight private attribute. Setter of this property should make sure new value is positive, otherwise should throw a ValueError exception saying "Weight must be positive" and NOT update the _weight attribute. d. Add a _str_method that returns a string of the form "Item Weight: weight" e. Make the Furniture class comparable. The comparison should be based on the weight property. (which special methods do you need to add here?) 2) Add a Table class which is derived from the Furniture class. a. Add an additional public attribute wood that represents the material the table is made from. b. Add a constructor that takes two parameters: weight in lbs and wood. Should throw an exception if weight is less than or equal to 0 or wood argument is not a string (Hint: you can use the isinstance built-in function to check the class of the argument to be str) C. Add a _str_() method that returns a string that says: Table Item Weight: weight Made of wood." where the value of weight comes from its weight property and the value of wood comes from its wood property. This method should use the string returned by the base class _str_method. 3) Add a Bed class which is also derived from the Furniture class. a. Add a public attribute size that represents the size of the bed. Allowed values: "Twin", "Full", "Queen", and "King" b. Add a constructor that takes two parameters: weight in lbs and size. The constructor should throw an exception if weight is less than or equal to 0 or size argument is not one of the allowed values. C. Add a _str_() method returns a string that says: "Bed Item Weight: weight Size: size" where the value of weight comes from its weight property and the value of size comes from its size property. This method should use the string returned by the base class_str_method. 4) Add a Furniture Gallery class. a. Add a private attribute called _furnList which is a list of Furniture class (and derived classes) objects. b. Add a constructor with no arguments that initializes the_furnList to empty list. C. Add a method called addFurniture that takes an argument which is supposed to be a Furniture class (or derived class) object. Method should verify that the argument is one of the Furniture or derived classes and add it to _furnlist. d. Add a sort method that sorts the_furnList list based on weight. e. Make this class iterable so that it can be used in a for-loop to iterate over the objects in the list. (What special method do you need to add here?) 5) Write all the four the classes in a single file called furniture.py. Now run the provided furnitureClient.py file. It should run without errors and should give the output as shown in the screenshot of the sample run below. NOTE: you shouldn't modify the client code. It just has to run correctly and give output as shown in the screenshot below. IDLE Shell 3.9.2 Eile Edit Shell Debug Options Window Help ASIANI. Wir coue/ TYPOWY riayy uund-120/A319.Men S7 LULUCULE-CLIC-PY Adding...O .... Success Adding... 1 .... Success Adding... 2 Weight cannot be negative Adding... 3 Wood should be of type string Adding... 0 .... Success Adding... 1 .... Success Adding... 2 .... Success Table Item Weight: 100 lbs Made of: Pine Table Item Weight: 75 lbs Made of: Oak Bed Item Weight: 200 lbs Size: King Bed Item Weight: 150 lbs Size: Queen Bed Item Weight: 95 lbs Size: Twin After sorting Table Item Weight: 75 lbs Made of: Oak Bed Item Weight: 95 lbs Size: Twin Table Item Weight: 100 lbs Made of: Pine Bed Item Weight: 150 lbs Size: Queen Bed Item Weight: 200 lbs Size: King >>> >>> Ln: 32 Col: 4

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