zoukankan      html  css  js  c++  java
  • 类,实例,属性习题


    class Restaurant():
    def __init__(self,restaurant_name,cuisine_type):
    self.restaurant_name=restaurant_name
    self.cuisine_type=cuisine_type

    def describle_restaurant(self):
    print("打印的第一条消息")
    print("打印的第二条消息")
    def open_restaurant(self):
    print("打印的最后一条消息")

    new_res=Restaurant("小东",'餐厅')
    print(new_res.cuisine_type)
    print(new_res.restaurant_name)
    new_res.describle_restaurant()
    new_res.open_restaurant()

    new_res1=Restaurant("娟娟","医院")
    new_res1.describle_restaurant()

    new_res2=Restaurant("lli","火锅馆")
    new_res2.describle_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("My name is "+self.first_name+' '+self.last_name)

    def describe_restaurant(self):
    print("My first name is "+self.first_name)
    print("My last name is "+self.last_name)

    user1=User("gong","shelldon")
    user1.describe_restaurant()
    user1.describe_user()
  • 相关阅读:
    第02组 团队项目-需求分析报告
    团队项目-选题报告
    第二次结对编程作业
    第2组 团队展示
    Alapha冲刺(3/6)
    Alpha(2/6)
    Alpha冲刺(1/6)
    第2组 团队Git现场编程实战
    团队项目-需求分析报告
    团队项目-选题报告
  • 原文地址:https://www.cnblogs.com/gshelldon/p/10494989.html
Copyright © 2011-2022 走看看