类设计:设计卖车的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()

  

posted @ 2018-05-08 17:09  汪凡  阅读(154)  评论(0编辑  收藏  举报