Ejemplo n.º 1
0
    def validateRectangle(value, errorMessage):
        if not isinstance(value, Rectangle):
            raise ShapeException(errorMessage)

        Line.validateLine(value.line1, "Line 1 is not a valid line.")
        Line.validateLine(value.line2, "Line 2 is not a valid line.")
        Line.validateLine(value.line3, "Line 3 is not a valid line.")
        Line.validateLine(value.line4, "Line 4 is not a valid line.")

        Validator.validateLinesFormLoop([value.line1, value.line2, value.line3, value.line4], "Lines do not form an enclosed rectangle.")

        Validator.validateLinesFormRightAngles([value.line1, value.line2, value.line3, value.line4], "Lines do not form 90 degree angles.")
Ejemplo n.º 2
0
    def validateEllipse(value, errorMessage):
        if not isinstance(value, Ellipse):
            raise ShapeException(errorMessage)

        Line.validateLine(value.axis1, "Axis1 is not a valid line")
        Line.validateLine(value.axis2, "Axis2 is not a valid line")

        if value.computeArea() <= 0:
            raise ShapeException(errorMessage)

        Validator.validateLinesFormRightAngles([value.axis1, value.axis2],
                                               "Axis are not perpendicular")