zoukankan      html  css  js  c++  java
  • 类设计:设计卖车的4S店

    class Car(object):
        # 定义车的方法
        def move(self):
            print('---车在移动---')
        def stop(self):
            print('---停车---')
    
    # 定义一个销售车的店类
    class CarStore(object):
        def order(self):
            car = Car() # 找一辆车
            return car
    
    # 1.先得有个销售汽车的店铺
    car_store = CarStore()
    # car_store.order().move()
    # 2.通过这家店订车
    my_car = car_store.order()
    # 3.开车爽
    my_car.move()
    my_car.stop()
    

      

                                                                       -------  知识无价,汗水有情,如需搬运请注明出处,谢谢!

  • 相关阅读:
    什么是“方法”
    break与continue
    循环结构2
    循环结构1
    Switch多选择结构
    if选择结构
    Scanner方法
    Doc参数信息
    运算符号
    变量与常量
  • 原文地址:https://www.cnblogs.com/wf-skylark/p/9009419.html
Copyright © 2011-2022 走看看