Sale!

Class Rectangle represents a 2D (axis-parallel) rectangle….solved

$25.00 $21.25

Category:

Description

5/5 - (5 votes)

Class Rectangle represents a 2D (axis-parallel) rectangle that a user can draw on a
computer screen. Think of a computer screen as a 2D map where each position has an x and a
y coordinate.
The data that each object of type Rectangle should have (and that should be populated in
the constructor, i.e., __init__ method of the class Rectangle) are:
* two Points: the first point representing the bottom left corner of the rectangle and the
second representing the top right corner of the rectangle; and,
* the color of the rectangle
Note that the two points (bottom left and top right) completely determine (the axis
parallel) rectangle and its position on the map. There is no default rectangle.
The __init__ method of Rectangle (that is invoked by the constructor Rectangle) will take
two objects of class Point as input and a string for the color). You may assume that the
first point (sent to the constructor, i.e. __init__) will always have smaller than or
equal x coordinate than the x coordinate of the second point and smaller than or equal y
coordinate than the y coordinate of the second point.

Class Rectangle should have 13 methods. In particular, in addition to the constructor
(i.e. __init__ method) and three methods that override python’s object methods (and make your class user friendly as suggested by the test cases), your class should contain the
following 9 methods:
get_bottom_left, get_top_right, get_color, reset_color, get_perimeter, get_area, move,
intersects, and contains.
Here is a description of three of those methods whose job may not be obvious from the test
cases.