为什么16和38行显示出错?
来源:2-6 编程练习
慕先生2341358
2020-07-15 22:42:25
class Point(object):
# 自定义Point类的构造(初始化)方法
def __init__(self,x,y):
self.x = x
self.y = y
# 自定义Point类对象的格式化输出函数(string())
def string(self):
print("该图形初始化点为:X:{0}, Y:{1}".format(self.x,self,y))
class Circle(Point):
# 自定义Circle类的构造(初始化)方法
def __init__(self,x,y,redius):
super (Circle,self).__init__(x,y)
self.redius = redius
# 自定义Circle类对象的格式化输出函数(string())
def string(self):
print("该图形初始化点为:{X:{0},Y{1};},{{半径为:{2}}".format(self.x,self.y,self.redius))
class Size(object):
# 自定义Size类的构造(初始化)方法
def __init__(self,Width,Height):
self.Width = Width
self.Height = Height
# 自定义Size类对象的格式化输出函数(string())
def string(self):
print("长宽分别为:{Width:{0},Heigh{1}".format(self.Width,self.Height))
class Rectangle(Point, Size):
# 自定义Rectangle类的构造(初始化)方法,并在方法中调用父类的初始化方法以完成初始化
def __init__(self,x,y,Width,Height):
Point.__init(x,y)
Size.__init__(Width,Height)
# 自定义Rectangle类对象的格式化输出函数(string())
def string(self):
super(Rectangle,self).string()
super(Rectangle,self).string_1()
if __name__ == "__main__":
# 实例化Circle对象,圆心为(5,5),半径为8
circle = Circle(5,5,8)
circle.string()
# 实例化Rectangle对象,顶点位置(15,15),长和宽分别为15和15
rectangle = Rectangle(15,15,15,15)
rectangle.string()
# 实例化Rectangle对象,顶点位置(40,30),长和宽分别为11和14
rectangle = Rectangle(40,30,11,14)2回答
好帮手慕燕燕
2020-07-16
同学自己解决了问题,棒棒哒,继续加油。
祝学习愉快~~~~
慕先生2341358
提问者
2020-07-16
已解决。。
相似问题