python烤地瓜之调味

class diGua():
def __init__(self):
self.cooking="生"
self.time=0
self.addItem=[]
def __str__(self):
return "%d分钟地瓜已经%s,添加了:%s"%(self.time,self.cooking,str(self.addItem))
def cook(self,cookTime):
self.time=self.time+cookTime
if 0<=self.time<=3:
self.cooking = "生"
elif 3<self.time<=5:
self.cooking = "半生半熟"
elif 5<self.time<=8:
self.cooking="熟"
elif 8<self.time:
self.cooking="烤焦"
def add(self,item):
self.addItem.append(item)
di_gua=diGua()

di_gua.cook(2)
di_gua.add("番茄酱")
print(di_gua)
di_gua.cook(2)
di_gua.add("芥末")
print(di_gua)
di_gua.cook(2)
di_gua.add("五香粉")
print(di_gua)

猜你喜欢

转载自www.cnblogs.com/w331842/p/12945855.html
今日推荐