python coding
need format and output screen
base the code I given(for 1st step)?finish rest of them(step2 to step8)
My code
class Rectangle:
def __init__(self, width, height, x, y):
self.__width = width
self.__height = height
self.__x = x
self.__y = y
def getWidth(self):
return self.__width
def getHeight(self):
return self.__height
def getX(self):
return self.__x
def getY(self):
return self.__y
r = Rectangle(10, 20, 1, 4)
print('Rectangle Width:', r.getWidth())
print('Rectangle height:',r.getHeight())
print('Rectangle coordinates: (',r.getX(), ', ', r.getY(), ')', sep='')
questions
???????
Design a class named Rectangle to represent a rectangle. The class should contain the following details: 1. Four data fields/attributes: width, height, xcoord, and ycoord - width: represents the width of the rectangle - height: represents the height of the rectangle - xcoord: represents the \( \mathrm{x} \)-coordinate point of the origin of the rectangle. The \( \mathbf{x} \) in the \( (x, y) \) on the graph to the right. - ycoord: represents the \( \mathrm{y} \)-coordinate point of the origin of the rectangle. The \( y \) in the \( (x, y) \) on the graph to the right.
2. A constructor that creates a rectangle with the specified width, height, xcoord, and ycoord 3. The default values are 1 and 2 for the width and height, respectively. The default values are 0 and 0 for the \( x \) coord and \( y \) coord. 4. A method named get_Area that returns the area value of this rectangle. 5. A method named get_Perimeter that returns the perimeter value of this rectangle 6. A method named get_Coordinates that returns the four pairs of \( \mathrm{x} \) - and \( \mathrm{y} \)-coordinates that mark where the four corners of this rectangle. Return these four \( (\mathrm{x}, \mathrm{y}) \) coordinates in a tuple of tuples. 7. Set the __str_ magic method to display the width, height, area, and perimeter of each rectangle in this order 8. Write a function, area_difference that takes two Rectangle instances as parameters and returns the signed difference in area between them. "signed difference" means that rather than always returning a positive number, the sign of the return value should be negative if the first rectangle is smaller than the second rectangle.