그 클래스에서 작성할 수있는 클래스를 작성해야합니다.수업을 목록에 넣으십시오. 파이썬
class Drawing(Circle, Square):
list = []
def addShape(self, theShape, colour, x, y, side):
self.list += [self.theShape(colour, x, y, side)]
def display(self):
return self.list
def move(self):
def changeColour(self, newColour):
def totalArea(self):
return
class Shape(Point):
def __init__(self, colour, x, y):
Point.__init__(self, x, y)
self.colour = colour
self.centrePoint = (x,y)
def centre(self):
return self.centrePoint
def movePoint(self, newX, newY):
Point.move(self, newX, newY)
self.centrePoint = (self.x, self.y)
class Circle(Shape):
def __init__(self, colour, x, y, radius):
Shape.__init__(self, colour, x, y)
self.radius = radius
def getArea(self):
return math.pi * (self.radius * self.radius)
에는 사각형 클래스가 더해집니다.
어떻게 색 등을 추가하고 클래스 이름을 목록에 추가하여 사용할 수 있습니까? 또는이 일을하는 가장 좋은 방법.
thanks
'addShapes'는 무엇을 의미합니까? 'Shape' 인스턴스의 목록 만 원합니까? 인스턴스의 모양이 어떤 것인지 알거나 인스턴스에 draw()를 호출하여 인스턴스에 인스턴스의 수행 방법을 알려 주어야합니까? – unholysampler
질문의 명확성을 위해 노력하십시오. 좋은 답변을 얻는 데 도움이 될 것입니다. – NPE
필자가해야 할 클래스를 추가했습니다. – Tom