class Restaurant():
"""describe the name of restaurant and cusine type of the restaurant"""
def __init__(self, restaurant_name, cuisine_type):
"""initialize attribute of name and cuisine type"""
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
self.number_served = 0
def describe_restaurant(self):
print(self.restaurant_name.title() + " focus on "
+ self.cuisine_type.title() + ".")
def open_restaurant(self):
print(self.restaurant_name + " is opening!")
def served_number(self):
print(self.restaurant_name.title() + " has "
+ str(self.number_served) + " people served ever.")
class IceCreamStand(Restaurant):
"""a special restaurant"""
def __init__(self, restaurant_name, cuisine_type = 'ice cream'):
""" initialize attribute"""
super().__init__(restaurant_name, cuisine_type)(不能運行,卡這里了)
self.flavors = []
def show_flavors(self):
print("\nWe have the following flavor of ice creams:")
for flavor in self.flavors:
print("- " + flavor.title())
smaller_one = IceCreamStand('dairy queen')
smaller_one.flavors = ['vanilla', 'strewberry', 'plain', 'chocolate', 'oreo']
print(smaller_one.describe_restaurant())
print(smaller_one.open_restaurant())
print(smaller_one.served_number())
smaller_one.show_flavors()
uj5u.com熱心網友回復:
用的是python3.8, sublime text
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/109428.html
上一篇:急,求解救,python的郵件功能例外,使用一段時間后軟體報錯,特意把郵件模塊摘出來
下一篇:求問大神
