Question: For this question, write a .pyfile and attach it as your answer. Write a class definition for a class named Rectangle. The Rectangle class should
For this question, write a .pyfile and attach it as your answer.
Write a class definition for a class named Rectangle. The Rectangle class should have data attributes for the
Rectangle's length, width and area.The class should include the following:
- An __init__ method for the class. The method should accept an argument for each of the length and width attributes.
- Setter and getter methods for the Rectangle's length.
- Setter and getter methods for the Rectangle's width.
- calculate_area method that calculates the Rectangle's area.
- A __str__ method that returns a string indicating the state of the object
- Your program should include a main method that would do the following:
- Create a Rectangle object
- Calla getter method of one of the attributes
- Call a setter method of one of the attributes
- Call the calculate_area method
- Print the object state
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
