Question: Rug Create a class called Rug that inherits from Rectangle. Then give the Rug class a price variable. The length, width and price of the

Rug
Create a class called Rug that inherits from Rectangle. Then give the Rug class a price variable. The length, width and price of the Rug should be set in the constructor of the Rug class. Give the Rug class a getPrice() method that returns the price. Also give the Rug class an overridden __str__() method that returns a string that is a report on the data in a Rug object.
Carpet
Create another class called Carpet that also inherits from Rectangle. It should have a price_per_square_foot variable. The length, width, and price_per_square_foot are set in the constructor of the Carpet class. Give the Carpet class a getPrice() method that calculates the price of the Carpet and returns it. Also give the Carpet class an overridden __str__() method that returns a string that is a report on the data in a Carpet object.
Create main.py
You should have a file for main.py which has the main() function inside. You will import the Carpet and Rug objects. Create an even number of Rug objects and an odd number of Carpet objects. Each of those objects should be put into a List object. Then code a loop that iterates through the List and uses the __str__() method to print a description of each object 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!