PYTHON 一个程序,23行有错,不明白为什么 敬请指教!
class Rectangle: def __init__(self, width, height): self.width = width self.height = height def paint(self, factory): point = factory.getPoint() corner = factory.getCorner() corner.leftUp() point.line(self.width - 2) corner.rightUp() print() for i in range(self.height - 2): point.line(self.width) print() corner.leftDown() point.line(self.width - 2); corner.rightDown(); print() class Dot: def line(self, width): for i in range(width): print("-",end="")class Sharp: def leftUp(self): print("#", end="") def rightUp(self): print("#", end="") def leftDown(self): print("#", end="") def rightDown(self): print("#", end="")class DotSharpFactory: def getPoint(self): return Dot() def getCorner(self): return Sharp() rect = Rectangle(20, 10)rect.paint(DotSharpFactory())