class Meal:
'''class meal test'''
def _init_(self,food='omelet',drink='coffee'):
self.name='generic meal'
self.food=food
self.drink=drink
def printIt(self,pprefix=''):
'''print the data nicely.'''
print(prefix,self.name.self.food,self.drink)
# Setter for the food.
def setFood(self,food='omelet'):
self.food=food
# Setter for the drink.
def setDrink(self,drink='coffee'):
self.drink=drink
# Setter for the name.
def setName(self,name=''):
self.name=name
class Lunch(Meal):
'''继承类测试'''
def _init_(self):
'''初始化'''
Meal._init_(self)
self.setName('midday meal');
# Override setFood().
def setFood(self,food='sandwich'):
raise AngryCheffException
Meal.setFood(self,food)