技术开发 频道

ABAP与设计模式之工厂方法模式

    具体创建类:

    *Now we can define the concrete creator

    
class ny definition inheriting from pizzastore.

    
protected section.

    methods:

    createpizza redefinition.

    endclass.

    
class ny implementation.

    method createpizza.

    
case pz_name2.

    when
'cheese'.

    create object pz type nystylepizza1.

    when
'vegie'.

    when
'clam'.

    when
'pepperoni'.

    endcase.

    endmethod.

    endclass.

    
class chi definition inheriting from pizzastore.

    
protected section.

    methods:

    createpizza redefinition.

    endclass.

    
class chi implementation.

    method createpizza.

    
case pz_name2.

    when
'cheese'.

    create object pz type chistylepizza1.

    when
'vegie'.

    when
'clam'.

    when
'pepperoni'.

    endcase.

    endmethod.

    endclass.
0
相关文章