zoukankan      html  css  js  c++  java
  • 编写类-餐馆类

    # Author Eric Zhao 
    # -*- coding:utf-8 -*-
    class Restaurant():
    """ 餐馆类 """
    def __init__(self,restaurant_name,cuisine_type):
    """ 始化属性 restaurant,cuisine_type """
    self.restaurant_name = restaurant_name
    self.cuisine_type = cuisine_type
    self.number_served = 100

    def describe_restaurant(self):
    """ 方法:餐馆描述"""
    print(" " + self.restaurant_name.title() + " is located on Northeast Street 4.")
    print("Cuisine type is "+self.cuisine_type.title()+"!")

    def open_restaurant(self):
    """ 方法:餐馆营业 """
    print(self.restaurant_name.title() + " is open. ")

    def read_number_served(self):
    """ 方法:打印已经在餐馆就餐过的人数 """
    print('We have served '+ str(self.number_served) + ' guests and you will be next.')

    def set_number_served(self,new_number):
    """ 方法:设置就餐人数 """
    if self.number_served < new_number:
    self.number_served = new_number
    print('set_num We have served ' + str(self.number_served) + ' guests and you will be next.')

    def increment_number_served(self,incr_num):
    """ 方法:增加就餐人数 """
    if incr_num >= 1:
    self.number_served += incr_num
    print('incr_num We have served ' + str(self.number_served) + ' guests and you will be next.')




    northeast_restaurant = Restaurant('Big Pot Fish','stewing')
    northeast_restaurant.describe_restaurant()
    northeast_restaurant.read_number_served()
    northeast_restaurant.set_number_served(50)
    northeast_restaurant.increment_number_served(30)

    northwest_restaurant = Restaurant('Northwest Beef Ramen','baking')
    northwest_restaurant.describe_restaurant()
    northwest_restaurant.read_number_served()

    '''
    sichuan_restaurant = Restaurant('Sichuan Imperial Palace','chili')
    sichuan_restaurant.describe_restaurant()
    sichuan_restaurant.read_number_served()
    '''

  • 相关阅读:
    codeforces 439C 模拟
    codeforces 435B
    【WebVR】AFrame中的A-sky无法利用src指定路径显示全景图
    【UE4】添加头文件之后VS中UCLASS()报错问题解决办法
    【UE4】蓝图之间的通讯
    git中报unable to auto-detect email address 错误的解决办法
    2017ACM省赛总结与生涯回顾
    hihocoder#1121 : 二分图一•二分图判定
    hihocoder#1039 : 字符消除
    2048low版
  • 原文地址:https://www.cnblogs.com/abarcher/p/10917856.html
Copyright © 2011-2022 走看看