Class Shape Constructor has 4 parameters and 4 attributes to be listed in this order: numSides, shapeName, nameAnchor, and messageAnchor. All four attributes should be private. Methods: displayName and displayNumSides both accept a window object as a parameter. Each should create and draw a Text object from the graphics library to display the appropriate information. nameAnchor is the point at which the name will be displayed and messageAnchor is where the message will be displayed. Class Square, Ball¹, Triangle, and Octagon Constructors should accept 2 parameters for the nameAnchor, and messageAnchor. It will call the super class constructor and pass in the correct number of sides and name for the shape, as well as the name and message anchor passed by parameter Each class should aslo have a drawShape method that accepts a window object as a parameter. It will then build the appropriate shape from the graphics library and draw it appropriately.
this is given code
ShapeLab.py
# create classes here and their methods
def main():
win = GraphWin("Shape Test", 600, 600)
l1 = Line(Point(300, 0), Point(300, 600))
l2 = Line(Point(0, 300), Point(600, 300))
l1.draw(win)
l2.draw(win)
shapes = []
shapes.append(Square(Point(50, 20), Point(100, 280)))
# shapes.append(Ball(Point(350, 20), Point(400, 280))) # remove comment to test Ball
# shapes.append(Triangle(Point(50, 320), Point(100, 570))) # remove comment to test Triangle
# shapes.append(Octagon(Point(350, 320), Point(400, 570))) # remove comment to test Octagon
for shape in shapes:
shape.displayName(win)
shape.displayNumSides(win)
shape.drawShape(win)
win.getMouse()
win.close()
if __name__ == '__main__':
main()
in python please


Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images









