9-1
#9.1
class Restaurant():
def __init__(self,name,cuisine_type):
self.name=name
self.cuisine_type=cuisine_type
def describe_restaurant(self):
print("The restaurant's name is "+self.name+ ".")
print("The restaurant's cuisine type is "+self.cuisine_type+".")
def open_restaurant(self):
print("The restaurant is open now.")
9-2
#9.2
restaurant_a=Restaurant('A','type_A')
restaurant_a.describe_restaurant()
restaurant_b=Restaurant('B','type_B')
restaurant_b.describe_restaurant()
restaurant_c=Restaurant('C','type_C')
restaurant_c.describe_restaurant()
9-6
#9.6
#coding=gbk
class Restaurant():
def __init__(self,name,cuisine_type):
self.name=name
self.cuisine_type=cuisine_type
def describe_restaurant(self):
print("The restaurant's name is "+self.name+ ".")
print("The restaurant's cuisine type is "+self.cuisine_type+".")
def open_restaurant(self):
print("The restaurant is open now.")
class IceCreamStand(Restaurant):
def __init__(self,name,cuisine_type):
super().__init__(name,cuisine_type)
self.flavors={"flavor_1,flavor_2,flavor_3"}
def show_flavors(self):
print('含以下口味的冰淇淋:')
print(self.flavors)
ice=IceCreamStand("IceCreamStand","icecream")
ice.describe_restaurant()
ice.open_restaurant()
ice.show_flavors()
9.10
#9.10
import restaurant
my_restaurant = restaurant.Restaurant("a","b")
my_restaurant.describe_restaurant()
my_restaurant.open_restaurant()
