Question: Must be in Python 3.6 (please have a screen shot on the code) Please make sure it can run with out any error Here is
Must be in Python 3.6 (please have a screen shot on the code)
Please make sure it can run with out any error

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
2.(Tkinter: two rectangles intersect?) Using the Rectangle2D class you defined in Exercise 8.19, write a program that enables the user to point the mouse insidea rectangle and drag it. As the rectangle is being dragged, the label displays whether two rectangles overlap, as shown in Figure 12.19 7k Two Rectangles -I] | 7%. Two Rectangles Two rectangles don't intersect Two rectangles intersect rl r1 r2 r2 FIGURE 12.19 Check whether two rectangles are overlapping
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
