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

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!