赞
踩
class Restaurant():
这里写代码片
def init(self, restaurant_name, cuisine_type):
self.name = restaurant_name
self.cuisine_type = cuisine_type
def describe_restaurant(self):
print("Name:" + self.name)
print("cuisine type:" + self.cuisine_type)
def open_restaurant(self):
print("Welcome to our restaurant!")
a = Restaurant(‘A’, ‘Chicken’)
b = Restaurant(‘B’, ‘Mutton’)
print(a.name)
print(a.cuisine_type)
a.describe_restaurant()
a.open_restaurant()
print(b.name)
print(b.cuisine_type)
b.describe_restaurant()
b.open_restaurant()
class User():
def init(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
def describe_user(self):
print("User's name is " + self.first_name + ' ' + self.last_name)
def greet_user(self):
print("Hello, I'm " + self.first_name + ' ' + self.last_name + '!')
a = User(‘Allen’, ‘Walker’)
b = User(‘Tom’, ‘Sawyer’)
a.describe_user()
a.greet_user()
b.describe_user()
b.greet_user()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。