def prob_9_6(): ice1 = IceCreamStand('Pops') ice1.describe_restaurant() ice1.add_flavors('vanilla') ice1.show_flavors() ice1.add_flavors('chocolate', 'strawberry', 'peanut butter') ice1.show_flavors()
from restaurant import Restaurant, IceCreamStand restaurant = Restaurant("Lo de Charly", "parrilla") print(restaurant.restaurant_name) print(restaurant.cuisine_type) restaurant.describe_restaurant() restaurant.open() restaurant_luigi = Restaurant("Lugi's Manssion", "Italian cuisine") restaurant_sushi = Restaurant("Itamae sushi", "Oriental food") restaurant_luigi.describe_restaurant() restaurant_luigi.open() restaurant_sushi.describe_restaurant() restaurant_sushi.open() griddo = IceCreamStand("Griddo", "heladeria") griddo.describe_restaurant() griddo.show_flavors()
from restaurant import Restaurant, IceCreamStand #import2个类 rest_1 = Restaurant('Restaurant_1', 'Rice') print("现在餐厅的人数:" + str(rest_1.number_served)) #打印就餐人数 flavors_1 = ['strawberry', 'blueberry'] #口味1 icecream_1 = IceCreamStand('Yami', flavors_1) #创建Icecream类1 print("冰淇淋店1的名字:" + str(icecream_1.name)) print("口味:") icecream_1.show_flavors() #方法打印口味1 flavors_2 = ['chocolate', 'milk'] #口味2 icecream_2 = IceCreamStand('Oishi', flavors_2) #创建Icecream类2 print("冰淇淋店2的名字:" + str(icecream_2.name)) print("口味:") icecream_2.show_flavors() #方法打印口味2
"""导入restaurant模块""" from restaurant import Restaurant, IceCreamStand """创建Restaurant实例并打印目前服务的人数""" restaurant_1 = Restaurant("greatpizza", "pizza") restaurant_1.set_number_served(81) restaurant_1.read_number_served() print("\n") """创建两个IceCreamStand类的实例,打印每个冰激凌店的名字和所提供的冰激凌的口味""" IceCream1 = IceCreamStand("ice-cream_land", "icecream", ['strawberry', 'yogurt', 'cheese', 'milk']) IceCream1.describe_restaurant() IceCream1.show_flavors() IceCream2 = IceCreamStand("best_ice-cream", "icecream", ['chocolate', 'strawberry', 'milk']) IceCream2.describe_restaurant() IceCream2.show_flavors()
from restaurant import Restaurant,IceCreamStand #创建restaurant的实例 rest=Restaurant('sugar','American flavor') rest.set_number_served(30) rest.show_number_served() print() #创建两个IceCreamStand类的实例 flavorlist_1=['chocolate','strawberry','blueberry','original'] flavorlist_2=['lemon','chocolate','strawberry','blueberry'] print("实例1") my_IceCreamStand=IceCreamStand('icy','Chinese flavor',flavorlist_1) my_IceCreamStand.describe_restaurant() my_IceCreamStand.show_flavors() print("实例2") your_IceCreamStand=IceCreamStand('freezing','French flavor',flavorlist_2) your_IceCreamStand.describe_restaurant() your_IceCreamStand.show_flavors()
from restaurant import Restaurant, IceCreamStand my_restaurant = Restaurant('海底捞', '火锅') my_restaurant.set_number_served(600000) first_IceCreamStand = IceCreamStand('哈根达斯', '冰淇淋') first_IceCreamStand.flavors = ['比利时巧克力', '蓝莓口味', '抹茶口味'] first_IceCreamStand.show_flavors() second_IceCreamStand = IceCreamStand('DQ', '冰淇淋') second_IceCreamStand.flavors = ['奥利奥', '蒙布朗栗子', '樱桃口味'] second_IceCreamStand.show_flavors()
from restaurant import Restaurant, IceCreamStand restaurant = Restaurant('KFC', 'chicken') print(restaurant.name) print(restaurant.cuisine_type) restaurant.describe() restaurant.open() restaurants = [ restaurant, Restaurant('Pizza Hut', 'italian'), Restaurant('Mr. Salmon', 'asian'), ] for restaurant in restaurants: restaurant.describe() print(f"Restaurant has served {restaurants[0].number_served} customers.") restaurants[0].number_served = 42 print(f"Restaurant has served {restaurants[0].number_served} customers.") restaurants[0].set_number_served(101) print(f"Restaurant has served {restaurants[0].number_served} customers.") restaurants[0].increment_number_served(898) print(f"Restaurant has served {restaurants[0].number_served} customers.") ice_cream_stand = IceCreamStand("Ice Bear", ['chocolate', 'plom-bear']) ice_cream_stand.show_flavors()
titled = self.name + '\n' + self.type return titled.title() class IceCreamStand(Restaurant): def __init__(self, name, type): super().__init__(name, type) self.flavors = ['first', 'second', 'third'] def show_flavors(self): print(self.flavors) my_cream = IceCreamStand('eskimo', 'holodok') print(my_cream.describe_restaurant()) my_cream.show_flavors() print('---') class User(): def __init__(self, first_name, last_name): self.first_name = first_name self.last_name = last_name def describe_user(self): full_name = self.first_name + ' ' + self.last_name return full_name.title() class Admin(User):
from restaurant import Restaurant, IceCreamStand restaurant = Restaurant('泡面食堂', '苍蝇馆子') restaurant.describe_restaurant() restaurant.open_restaurant() icecreamstand = IceCreamStand('肯德基', '快餐店') icecreamstand.describe_restaurant() icecreamstand.show_flavors()
from restaurant import IceCreamStand res = IceCreamStand("哈更达斯", "icecream") res.show_flavors()
from restaurant import Restaurant, IceCreamStand restaurant1 = Restaurant("Szarotka", "Kuchnia regionalna") restaurant2 = IceCreamStand("Lodziarnia", "Budka z lodami") restaurant1.describe_restaurant() print("\n") restaurant2.show_flavors()
from restaurant import Restaurant,IceCreamStand ##建立一个餐馆,并显示服务人数 rest1 = Restaurant('qingfeng','chinese') rest1.set_number_served(200) rest1.show_number_served() ##定义两个列表,用于传递给对象 flavor1 = ['Strawberry','Chocolate','Vanilla','Matcha ', 'Strawberry','Coconut'] flavor2 = ['Strawberry','Chocolate','Vanilla','Matcha ', 'Caramel','Raspberry','Cheese'] ##建立两个冰淇淋店对象,并打印各自的口味 ice1 = IceCreamStand('love and you','american',flavor1) ice2 = IceCreamStand('encountering','icecream',flavor2) ice1.show_flavors() ice2.show_flavors()