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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 11PE
icon
Related questions
Question

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

 

 

 

You will be writing 5 classes for this assignment, a superclass called Shape, and 4 subclasses:
Square, Ball, Triangle, Octagon.
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.
Shape Test
Square
A Square has 4 sides
Triangle
A Triangle has 3 sides
Circle
A Circle has 0 sides
Octagon
A Octagon has 8 sides
Transcribed Image Text:You will be writing 5 classes for this assignment, a superclass called Shape, and 4 subclasses: Square, Ball, Triangle, Octagon. 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. Shape Test Square A Square has 4 sides Triangle A Triangle has 3 sides Circle A Circle has 0 sides Octagon A Octagon has 8 sides
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT