Question: Must be in Python 3.6 (please have a screen shot on the code) Here is 8.19: import math class Rectangle2D: def __init__(self, x = 0,

Must be in Python 3.6 (please have a screen shot on the code)

Must be in Python 3.6 (please have a screen shot on thecode) Here is 8.19: import math class Rectangle2D: def __init__(self, x =

Here is 8.19:

import math

class Rectangle2D:

def __init__(self, x = 0, y = 0, width = 0, height = 0):

self.x = x

self.y = y

self.width = width

self.height = height

def getX(self):

return self.x

def getY(self):

return self.y

def getWidth(self):

return self.width

def getHeight(self):

return self.height

def setHeight(self, x):

self.x = x

def setHeight(self, y):

self.y = y

def setWidth(self, width):

self.width = width

def setHeight(self, height):

self.height = height

def getPerimeter(self):

return 2 * (self.width + self.height)

def getArea(self):

return self.width * self.height

def containsPoint(self, x, y):

return abs(x - self.x)

def contains(self, r):

return self.containsPoint(r.x - r.width / 2, r.y + r.height / 2) and \

self.containsPoint(r.x - r.width / 2, r.y - r.height / 2) and \

self.containsPoint(r.x + r.width / 2, r.y + r.height / 2) and \

self.containsPoint(r.x + r.width / 2, r.y - r.height / 2)

def overlaps(self, r):

return abs(self.x - r.x)

abs(self.y - r.y)

def __contains__(self, anotherRectangle):

return self.contains(anotherRectangle)

def __lt__(self, secondRectangle):

return self.__cmp__(secondRectangle)

def __le__(self, secondRectangle):

return self.__cmp__(secondRectangle)

def __gt__(self, secondRectangle):

return self.__cmp__(secondRectangle) > 0

def __ge__(self, secondRectangle):

return self.__cmp__(secondRectangle) >= 0

# Compare two numbers

def __cmp__(self, secondRectangle):

if self.getArea() > secondRectangle.getArea():

return 1

elif self.getArea()

return -1

else:

return 0

**12.9 (Tkinter: two rectangles intersect?) Using the Rectangle2D class you defined in Exercise 8.19, write a program that enables the user to specify the location and size of the rectangles and displays whether the two rectangles intersect, as shown

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!