9-1
class Restaurant():
def __init__(self,restaurant_name,cuisine_type):
self.restaurant_name=restaurant_name
self.cuisine_type=cuisine_type
def describe_restaurant(self):
print(self.restaurant_name.title()+" with "+self.cuisine_type.title())
def open_restaurant(self):
print("The restaurant is open!")
restaurant=Restaurant("fy","western")
restaurant.describe_restaurant()
restaurant.open_restaurant()
9-2
class Restaurant():
def __init__(self,restaurant_name,cuisine_type):
self.restaurant_name=restaurant_name
self.cuisine_type=cuisine_type
def describe_restaurant(self):
print(self.restaurant_name.title()+" with "+self.cuisine_type.title())
def open_restaurant(self):
print("The restaurant is open!")
restaurant_1=Restaurant("fy","western")
restaurant_1.describe_restaurant()
restaurant_2=Restaurant("wzy","chinese")
restaurant_2.describe_restaurant()
restaurant_3=Restaurant("xmz","guangdong")
restaurant_3.describe_restaurant()
9-3
class User():
def __init__(self,f_name,l_name,lover):
self.first_name=f_name
self.last_name=l_name
self.lover=lover
def describe_user(self):
print("Name:"+self.first_name.title()+" "+self.last_name.title()
+" "+"Lover:"+self.lover.title())
def greet_user(self):
print("Hello, my dear "+self.first_name.title()+"!")
user_1=User("bro","fang","cody")
user_1.describe_user()
user_1.greet_user()
user_2=User("cody","zhang","bro")
user_2.describe_user()
user_2.greet_user()
user_3=User("ning","han","henan")
user_3.describe_user()
user_3.greet_user()