Respuesta :
Answer:
Explanation:
The following code is written in Python and creates a Rectangle class that performs all the necessary functions mentioned in the question...
from itertools import count
class Rectangle():
_ids = count(0)
width = 1.0
height = 1.0
def __init__(self, width, height):
if (width < 0) or (height < 0):
raise Exception("Sorry, no numbers below zero")
else:
self.id = next(self._ids)
self.width = width
self.height = height
def get_width(self):
return self.width
def get_height(self):
return self.height
def set_width(self, width):
if width > 0:
self.width = width
def set_height(self, height):
if height > 0:
self.height = height
def get_area(self):
return (self.height * self.width)
def get_perimeter(self):
return ((self.height * 2) + (self.width * 2))
def rotate(self):
temp = self.height
self.height = self.width
self.width = temp
def get_count(self):
return self._ids
def equality(self, rectangle1, rectangle2):
if rectangle1 == rectangle2:
return True
else:
return False
def __str__(self):
return 'Rectangle Object with Height: ' + str(self.height) + ' and Width: ' + str(self.width)