zoukankan      html  css  js  c++  java
  • 设计模式 模版模式

    class CarTemplate:
        def __init__(self):
            pass
        def wheel(self):
            return ('4个轮子,牌子是:');
        def engine(self):
            return ('一个发动机,牌子是:')
        def frame(self):
            return ('一个车架,牌子是:')
    
        def show(self):
            self.wheel()
            self.engine()
            self.frame()
    
    class BMWCar(CarTemplate):
        def wheel(self):
            print(super().wheel() + '宝马')
    
        def engine(self):
            print(super().engine() + '宝马')
        def frame(self):
            print(super().frame() + '宝马')
    
    class AuditWCar(CarTemplate):
        def wheel(self):
            print(super().wheel() + '奥迪')
    
        def engine(self):
            print(super().engine() + '奥迪')
        def frame(self):
            print(super().frame() + '奥迪')
    
    if __name__=='__main__':
        car = BMWCar()
        car.show()
        car = AuditWCar()
        car.show()
  • 相关阅读:
    [bzoj3123] [Sdoi2013]森林
    [bzoj2173] 整数的lqp拆分
    Linux
    使用高德地图API
    EF具体用在什么类型的项目上
    出现Data Tools 与VS 不兼容问题
    Entity FramWork
    Entity
    Entity
    BASH
  • 原文地址:https://www.cnblogs.com/agang-php/p/9969292.html
Copyright © 2011-2022 走看看