class Color():
def __init__(self,index = 0):
self.set_color = ['white','red','black','green']
self.index = index
def setColor(self):
return self.set_color[self.index]
class Box1():
'''求立方体体积的类'''
def __init__(self,lenght1,width1,height1,c1 = 0):
self.lenght = lenght1
self.width = width1
self.height = height1
self.color = Color(c1).setColor()
def volume(self):
return self.height*self.width*self.lenght
my_box1 = Box1(10,10,10,1)
print('立方体体积是%d'%(my_box1.volume()))
print(my_box1.color)
print(type(Box1))
第13行的参数为啥是写到Color()里面?在定义Color的时候不是不带参数的吗?