At Westonci.ca, we make it easy for you to get the answers you need from a community of knowledgeable individuals. Get detailed answers to your questions from a community of experts dedicated to providing accurate information. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.
Sagot :
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)
Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. We hope this was helpful. Please come back whenever you need more information or answers to your queries. We're glad you visited Westonci.ca. Return anytime for updated answers from our knowledgeable team.