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 #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
# Importing methods from restaurant module. from restaurant import Restaurant, IceCreamStand # example data: my_restaurant = Restaurant('qs', 'fast food') my_restaurant.describe_restaurant() my_restaurant.open_restaurant() # example data: my_stand = IceCreamStand('Pennys', 'ice cream shoppe') my_stand.describe_restaurant() my_stand.describe_ice_cream_flavors()
# 9.10 - Imported Restaurant from restaurant import Restaurant, IceCreamStand my_stand = IceCreamStand('Wonderland') my_stand.describe_restaurant() my_stand.describe_flavors()
from restaurant import Restaurant, IceCreamStand # or this, but not recomended -> from restaurant import * my_restaurant = Restaurant('McDonalds', 'fast food') # print(my_restaurant.restaurant_name) my_restaurant.describe_restaurant() restaurant = Restaurant('Mek Shop', 'Malay') print(restaurant.number_served) restaurant.set_number_served(20) print(restaurant.number_served) restaurant.increment_number_served(10) print(restaurant.number_served) my_ice_cream_stand = IceCreamStand('Baskin Robins', 'Ice Cream', ['vanilla', 'chocolate']) print(my_ice_cream_stand.restaurant_name) print(my_ice_cream_stand.cuisine_type) print(my_ice_cream_stand.flavors)
from restaurant import Restaurant, IceCreamStand goracy_piec = Restaurant("Gorący Piec", "Pizzeria") goracy_piec.describe_restaurant() przystan = IceCreamStand("Przystań", "Lodziarnia") przystan.describe_restaurant()
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 r1 = Restaurant("BestRestaurant", "Chinese food") r1.set_number_served(10) print("The number of people the restaurant served is:" + str(r1.number_served)) r1.increment_number_served(20) print("There are " + str(r1.number_served) + " people have been served.") from restaurant import IceCreamStand Icecream1 = IceCreamStand("LittleGirl", "dessert") Icecream2 = IceCreamStand("MyFavorite", "dessert") Icecream1.describe_restaurant() Icecream1.set_flavors(['orange', 'apple', 'banana']) Icecream1.describe_icecream() Icecream2.describe_restaurant() Icecream2.set_flavors(['strawberry', 'blue berry', 'melon']) Icecream2.describe_icecream()
from restaurant import IceCreamStand res = IceCreamStand("哈更达斯", "icecream") res.show_flavors()
# 福尔餐馆实例 restaurant = Restaurant('Fuer', 'cheese') # 打印餐馆的属性 print("The first restaurant is " + restaurant.restaurant_name + ".") print("The best cuisine of " + restaurant.restaurant_name + " is " + restaurant.cuisine_type + ".") # 调用类定义中的方法 restaurant.describe_restaurant() restaurant.open_restaurant() # 直接修改属性值 restaurant.read_number() restaurant.number_serverd = 320 restaurant.read_number() # 调用方法修改属性值 restaurant.set_number_serverd(500) restaurant.read_number() # 递增就餐人数 restaurant.increment_number_serverd(150) restaurant.read_number() # 冰淇淋小店实例 icecream_restaurant = IceCreamStand('Merlin ice', 'love') # 父类方法 icecream_restaurant.describe_restaurant() icecream_restaurant.open_restaurant() icecream_restaurant.set_number_serverd(200) icecream_restaurant.read_number() # 子类特有方法 icecream_restaurant.read_icecream()
from restaurant import Restaurant, IceCreamStand resto_1 = Restaurant("raffy's", "general") resto_1.describe_restaurant() resto_2 = IceCreamStand("gelato", "icecream") resto_2.describe_restaurant() resto_2.print_flavors()
from restaurant import Restaurant, IceCreamStand restaurant = IceCreamStand('starbucks', 'coffee') restaurant.flavor.desribe_flavor() print(restaurant.desribe_restaurant()) kyrgyz_restaurant = Restaurant('naavat', 'mix') chinese_restaurant = Restaurant('king palace', 'buffet') mediteranean_restaurant = Restaurant('dimassis', 'buffet') print(kyrgyz_restaurant.restaurant_name.title() + " is the best place with " + kyrgyz_restaurant.cuisine_type.title()) kyrgyz_restaurant.desribe_restaurant() chinese_restaurant.desribe_restaurant() mediteranean_restaurant.desribe_restaurant() kyrgyz_restaurant.years_served() kyrgyz_restaurant.set_number_served(5) kyrgyz_restaurant.years_served() kyrgyz_restaurant.increment_number_served(4) kyrgyz_restaurant.years_served()
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 restaurant1=Restaurant('KFC','fast food') restaurant1.number_served=100 restaurant1.describe_restaurant() restaurant1.set_number_served() from restaurant import IceCreamStand icecreamstand1=IceCreamStand('Ice Queen','icecream') icecreamstand1.describe_restaurant() icecreamstand1.flavors=['milk','chocolate'] icecreamstand1.describe_flavor() icecreamstand2=IceCreamStand('Ice House','icecream') icecreamstand2.describe_restaurant() icecreamstand2.flavors=['lemon'] icecreamstand2.describe_flavor()
from restaurant import Restaurant, IceCreamStand johns = IceCreamStand("John's", "Ice Cream", "Chocolate") johns.describe_flavours harvester = Restaurant('Harvester', 'general') harvester.describe_restaurant() harvester.increment_number_served(3) print(f"{harvester.number_served}")
from restaurant import Restaurant, IceCreamStand my_own_restaurant = Restaurant('abc', 'H') my_own_restaurant.describe_restaurant() my_own_restaurant.set_number_served(23) my_own_restaurant.get_number_served() fla1 = ['strawberry', 'milk', 'choclate', 'vanilla'] fla2 = ['strawberry', 'milk', 'choclate', 'seasalt'] ice1 = IceCreamStand('1', 'icecream', fla1) ice2 = IceCreamStand('2', 'icecream', fla2) ice1.describe_icecream() ice2.describe_icecream()
from restaurant import IceCreamStand, Restaurants richies = IceCreamStand(name='richies', cuisine_type='ice cream stand') richies.flavors = ['chocolate', 'vanilla', 'tart', 'cookies & cream'] richies.menu() richies.set_served(46) richies.increment_served(-98) richies.customers()
#! python3 print("Task 9.10") from restaurant import Restaurant, IceCreamStand ice = IceCreamStand('Ice World') ice.flavors = ['banana', 'vanilla', 'chocolate'] ice.describe_restaurant() ice.describe_flavors() print("Task 9.11") from users import Admin adrian = Admin('adrian', 'szymanski', 'zeus', '*****@*****.**', 'adrian88szymanski', 'sport', 'poland') adrian.describe_user() adrian.privileges.show_privileges() print("\nAdding privileges...") adrian_privileges = [ 'can add posts', 'can remove posts', 'can suspend accounts', ] adrian.privileges.privileges = adrian_privileges adrian.privileges.show_privileges()
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()
from restaurant import Restaurant, IceCreamStand from user import User, Admin if __name__ == '__main__': first_res = Restaurant("paprika", "italian") print(first_res.describe_restaurant()) print(first_res.open_restaurant()) second_res = Restaurant("samurai", "japanese") print(second_res.describe_restaurant()) ice_cream = IceCreamStand() ice_cream.describe_flavours() print("*******************") u1 = User() u1.greet_user() u2 = User("vlada", "radchenko", "123445", "female") u2.greet_user() u2.describe_user() u4 = User() print(u4.valid_tel()) new_user = User("Peter", "English") new_user.increment_login_attempts() new_user.increment_login_attempts() new_user.increment_login_attempts() new_user.reset_login_attempts() print("*******************") user = Admin("Vasya", "Ivanov", "0507678712", "male")
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 # 9-1. Restaurant restaurant = Restaurant('ooma', 'japanese') restaurant.describe_restaurant() restaurant.open_restaurant() # 9-2. Three Restaurants #res1 = Restaurant('mendokoro ramenba', 'japanese') #res2 = Restaurant('buffalo wings n things', 'tex mex') #res3 = Restaurant('mesa', 'filipino') #res1.describe_restaurant() #res2.describe_restaurant() #res3.describe_restaurant() # 9-4. Number Served #print("Number of customers served: " + # str(restaurant.number_served)) #restaurant.set_number_served(20) #print("Number of customers served: " + # str(restaurant.number_served)) #restaurant.increment_number_served(3) #print("Number of customers served: " + # str(restaurant.number_served)) # 9-6. Ice Cream Stand my_ice_cream_stand = IceCreamStand('dairy queen', 'soft serve') my_ice_cream_stand.describe_restaurant() my_ice_cream_stand.add_available_flavors('chocolate', 'vanilla') my_ice_cream_stand.display_flavors()
from restaurant import Restaurant, IceCreamStand restaurant = Restaurant("Seventh Taste", "Veggie") restaurant.describe_restaurant() restaurant.set_number_served(345) restaurant.increment_number_served(15) # Make an instance of the subclass. Inherited from the parent class. my_ice_cream = IceCreamStand("Straciatella", "Ice-cream") my_ice_cream.describe_restaurant() my_ice_cream.get_flavors()
from restaurant import Restaurant, IceCreamStand restaurant = Restaurant('泡面食堂', '苍蝇馆子') restaurant.describe_restaurant() restaurant.open_restaurant() icecreamstand = IceCreamStand('肯德基', '快餐店') icecreamstand.describe_restaurant() icecreamstand.show_flavors()
"""导入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()
def describe_restaurant(self): 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()
from restaurant import Restaurant, IceCreamStand #flavors = ['Vainilla', 'Strawberry','apple','banana','grapes'] italian_restaurant = Restaurant('Mamma mia', 'Italian') italian_restaurant.describe_restaurant() ice_restaurant = IceCreamStand('Freedo', 'Ice Cream Store') ice_restaurant.set_flavors('Vanilla', 'banana split', 'pistache', 'nutella') ice_restaurant.describe_restaurant() ice_restaurant.get_flavors()
from restaurant import Restaurant, IceCreamStand #创建Restaurant 实例 r1 = Restaurant('食堂', '各种餐点') r1.set_number_served(30) #创建IceCreamStand实例 r2 = IceCreamStand('ABC', 'icecream') r2.flavors = ['chocolate', 'cream', 'vanilia'] r2.show_the_flavor_of_the_icecreamstand() r3 = IceCreamStand('DEF', 'icecream') r3.flavors = ['chocolate', 'lemon', 'cream'] r3.show_the_flavor_of_the_icecreamstand()
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 restaurant1 = Restaurant("guggino's", "italian cuisine") restaurant1.describe_restaurant() print('\n') restaurant2 = IceCreamStand('diarhee-land', ['chocolate', 'vanilla']) restaurant2.describe_restaurant() restaurant2.describe_flavors_served() print('\n') restaurant3 = IceCreamStand('salmonella-land', ['raspberry', 'cookie dough', 'mint', 'lemon']) restaurant3.describe_restaurant() restaurant3.describe_flavors_served()