Question
I get how to find the parameter its just the other 3 parts im confused on 3.2.1 Consider the following data-type implementation for (axis-aligned) rectangles,
I get how to find the parameter its just the other 3 parts im confused on
3.2.1 Consider the following data-type implementation for (axis-aligned) rectangles, which represents each rectangle with the coordinates of its center point and its width and height:
class Rectangle:
# Create rectangle with center (x, y),
# width w, and height h.
def __init__(self, x, y, w, h):
self._x = x
self._y = y
self._width = w
self._height = h
# The area of self.
def area(self):
return self._width * self._height
# The perimeter of self.
def perimeter(self):
...
# True if self intersects other; False otherwise.
def intersects(self, other):
...
# True if self contains other; False otherwise.
def contains(self, other):
...
# Draw self on stddraw.
def draw(self):
Compose an API for this data type, and complete its implementation as a class by filling in the code for perimeter(), intersects(), contains(), and draw(). Note: Treat coincident lines as intersecting, so that, for example, a.intersects(a) is True and a.contains(a) is True.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started