Answered step by step
Verified Expert Solution
Link Copied!

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 : x-coordinate of the point
@dotsy : y-coordinate of the point
Two readonly Properties:
x : x-coordinate of the point
@y : y-coordinate of the point
A constructor:
This takes two required arguments: x and y coordinates
One Method:
translate(dx,dy): method moves the point by dx in x-direction and by dy in y-
direction (it updates the _x and _y attributes by adding dx and dy to them
respectively)
Create a Rectangle class with the following requirements:
Three static attributes:
DEFAULT_WIDTH (initialized to 1)
DEFAULT_HEIGHT (initialized to 1)
rectangleCount (initialized to 0, represents the count of rectangles
instantiated so far)
Attributes:
_topLeft: an instance of Point class that denotes the top-left corner of the
rectangle.
_ width: width of the rectangle (cannot be negative or 0)
@,_height: height of the rectangle (cannot be negative or 0)
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 0, the setter should check if client tries to set anfrom rectangle import Rectangle, Point
##Variable to enable/disable assert checks
# set this to False, if you don't want the checkRectangle and checkValue to be c
checkAll = True
def printRectangle(rect):
'' Function to print all the properties of a Rectangle object'''
print(f'Top: {rect.topLeft.y}, Left: {rect.topLeft.x}, Width: {rect.width},
f'Bottom: {rect.bottomRight.y}, Right: {rect.bottomRight.x}, Area: {re
def checkRectangle(rect, expected):
''' Function to check all the properties of a Rectangle object against the 1
provided in the second parameter (expected)'''
if (checkAll):
actual =[rect.topLeft.y, rect.topLeft.x, rect.width, rect.height,
rect.bottomRight.y, rect.bottomRight.x, rect.area, rect.perimet
for a,b in zip(actual, expected):
assert (a==b)
def checkValue(x, y):
if (checkAll):
assert(x==y)
def main():
starline =****50
dashline =-***50
print(starline+"
Testing Rectangle and Point classes.")
print (starline)
#data used to create 4 rectangles
# [left, top, width, height]
rawData =[12345678910012131415-4]
#Create 4 Rectangle objects using rawData
rectangles =[]
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

Explain what is meant by the terms unitarism and pluralism.

Answered: 1 week ago