我写了这个简单的代码,我认为它不包含语法错误但它不执行所以我认为这是一个逻辑错误:o,所以我需要帮助!有人可以救我吗?!:D
class NumberGenerator:
"""A simple class that contains functions to generate ranges of numbers"""
@classmethod
def generate(quantity, value=[]):
while quantity: value.append(quantity) ; quantity -= 1
return value
class Figure:
"""Abstract class for geometric figures"""
def init(self, name):
"""This is the constructor"""
self._name = name
def name(self):
return self._name
class Rectangle(Figure):
"""Rectangle figure"""
def init(self, width, height):
Figure.__init__("rectangle")
self._width = width
self._height = height
def width(self):
return self.width
def height(self):
return self.height
def size(self):
self.width() * self.height()
if __name__ == "__main__":
# We print the range(10,0,-1)
print NumberGenerator.generate(10)
# We print the range(20,0,-1)
print NumberGenerator.generate(20)
# We create a rectangle
r = Rectangle(10, 20)
print r.size()
# EOF