Computers and Technology

Implement a class named Rectangle. The class should contain: 1. Two data attributes of type float named width and height that specify the width and the height of the rectangle.
2. A constructor that creates a rectangle with the specified width and height. If no argument is provided, it should use 1.0 for both values. If any input value is negative, the function should raise an exception.
3. Functions get_width and get_height that return the corresponding value
4. The set_width and set_height function that update the values if and only if the input is positive; otherwise do nothing
5. Functions get_area and get_perimeter that return the area and the perimeter of this rectangle respectively.
6. A function rotate that swaps the height and width of a rectangle object.
7. A class variable count that keeps track of the number of rectangles created so far.
8. A class method get_count that returns the above value.
9. An equality operator that returns True if and only if the two rectangles are of the same shape.
10. A __str__ function that returns the information of this rectangle in some readable format.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 05:00, edjiejwi
Lisa has a section of her document that she would like to include in the index. which option should lisa choose? mark index mark entry insert endnote add text
Answers: 3
image
Computers and Technology, 22.06.2019 16:30, sayedaly2096
What type of file does a cookie place on web site visitors' computers so that web site managers can customize their sites to their visitors' preferences?
Answers: 1
image
Computers and Technology, 22.06.2019 21:30, mjweed2456
Nathan wants to create multiple worksheet containing common formatting styles for his team members. which file extension him to save these worksheets? nathan to create multiple worksheets with common styles. he needs to save them with the extension.
Answers: 1
image
Computers and Technology, 24.06.2019 00:30, rustjallison9928
Asecurity policy is a a. set of guidlines b. set of transmission protocols c. written document d. set of rules based on standards and guidelines
Answers: 2
Do you know the correct answer?
Implement a class named Rectangle. The class should contain: 1. Two data attributes of type float n...

Questions in other subjects:

Konu
Mathematics, 10.07.2019 15:30