赞
踩
class Restaurant():
def __init__(self,name,cuisine):
self.restaurant_name = name
self.cuisine_type = cuisine
def describe_restaurant(self):
print('名称:'+self.restaurant_name)
print('类型:'+self.cuisine_type)
def open_restaurant(self):
print('餐厅正在营业')
test1 = Restaurant('金贝子','食堂');
test1.describe_restaurant()
test1.open_restaurant()
class Restaurant():
def __init__(self,name,cuisine):
self.restaurant_name = name
self.cuisine_type = cuisine
def describe_restaurant(self):
print('名称:'+self.restaurant_name)
print('类型:'+self.cuisine_type)
def open_restaurant(self):
print('餐厅正在营业')
test1 = Restaurant('金贝子','食堂');
test1.describe_restaurant()
test1.open_restaurant()
test2 = Restaurant('湖畔君府','食堂');
test2.describe_restaurant()
test2.open_restaurant()
test2 = Restaurant('四饭','食堂');
test2.describe_restaurant()
test2.open_restaurant()
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
class Restaurant():
def __init__(self,name,cuisine):
self.restaurant_name = name
self.cuisine_type = cuisine
def describe_restaurant(self):
print('名称:'+self.restaurant_name)
print('类型:'+self.cuisine_type)
def open_restaurant(self):
print('餐厅正在营业')
class IceCreamStand (Restaurant):
def __init__(self,name,cuisine,flavors):
super(IceCreamStand,self).__init__(name,cuisine)
self.flavors = flavors
def describe_flavors(self):
for flavor in self.flavors:
print(flavor)
flavors = ['Mango','Straberry','Apple','Chocolate']
Shop = IceCreamStand('金贝子','食堂',flavors);
Shop.describe_restaurant()
Shop.open_restaurant()
Shop.describe_flavors()
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
名称:金贝子
类型:食堂
餐厅正在营业
Mango
Straberry
Apple
Chocolate
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。