示例#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.")
示例#2
0
    def validateTriangle(value, errorMessage):
        if not isinstance(value, Triangle):
            raise ShapeException(errorMessage)

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

        Validator.validateSlopesAreDifferent(
            [value.line1, value.line2, value.line3],
            "Angles of lines form an invalid triangle")

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