Answered step by step
Verified Expert Solution
Question
1 Approved Answer
two classes so that the client code provided in RectangleClient.py file works as expected. See Appendix for more information on the coordinate system these points
two classes so that the client code provided in
RectangleClient.py file works as expected. See
Appendix for more information on the coordinate system these points and rectangles are
expected to be placed. Specifically,
Create a Point class with the following requirements:
Attributes:
@dotsx : coordinate of the point
@dotsy : ycoordinate of the point
Two readonly Properties:
: coordinate of the point
@ : coordinate of the point
A constructor:
This takes two required arguments: and coordinates
One Method:
translatedxdy: method moves the point by in direction and by in
direction it updates the and attributes by adding and dy to them
respectively
Create a Rectangle class with the following requirements:
Three static attributes:
DEFAULTWIDTH initialized to
DEFAULTHEIGHT initialized to
rectangleCount initialized to represents the count of rectangles
instantiated so far
Attributes:
topLeft: an instance of Point class that denotes the topleft corner of the
rectangle.
width: width of the rectangle cannot be negative or
@height: height of the rectangle cannot be negative or
Three properties:
O topLeft: Getter should return the topLeft attribute and the setter should
update the topLeft attribute.
width: The getter method should return the
width attribute. Knowing that
width cannot be negative or the setter should check if client tries to set anfrom rectangle import Rectangle, Point
##Variable to enabledisable assert checks
# set this to False, if you don't want the checkRectangle and checkValue to be c
checkAll True
def printRectanglerect:
Function to print all the properties of a Rectangle object'
printfTop: recttopLeft.y Left: recttopLeft.x Width: rectwidth
f'Bottom: rectbottomRight.y Right: rectbottomRight.x Area: re
def checkRectanglerect expected:
Function to check all the properties of a Rectangle object against the
provided in the second parameter expected
if checkAll:
actual recttopLeft.y rect.topLeft.x rect.width, rect.height,
rect.bottomRight.y rect.bottomRight.x rect.area, rect.perimet
for in zipactual expected:
assert
def checkValuex y:
if checkAll:
assert
def main:
starline
dashline
printstarline
Testing Rectangle and Point classes."
print starline
#data used to create rectangles
# left top, width, height
rawData
#Create Rectangle objects using rawData
rectangles
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