forked from moreus/ABAPDesignPattern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zdp_strategy.abap
93 lines (74 loc) · 2.16 KB
/
zdp_strategy.abap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
*&---------------------------------------------------------------------*
*& Report ZDP_STRATEGY
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zdp_strategy.
INTERFACE strategy.
METHODS: algorithm.
ENDINTERFACE.
CLASS concrete_strategya DEFINITION.
PUBLIC SECTION.
INTERFACES: strategy.
ENDCLASS.
CLASS concrete_strategya IMPLEMENTATION.
METHOD strategy~algorithm.
WRITE: / 'Called Concreate Strategy A Algorithm Interface.'.
ENDMETHOD.
ENDCLASS.
CLASS concrete_strategyb DEFINITION.
PUBLIC SECTION.
INTERFACES: strategy.
ENDCLASS.
CLASS concrete_strategyb IMPLEMENTATION.
METHOD strategy~algorithm.
WRITE: / 'Called Concreate Strategy B Algorithm Interface.'.
ENDMETHOD.
ENDCLASS.
CLASS concrete_strategyc DEFINITION.
PUBLIC SECTION.
INTERFACES: strategy.
ENDCLASS.
CLASS concrete_strategyc IMPLEMENTATION.
METHOD strategy~algorithm.
WRITE: / 'Called Concreate Strategy C Algorithm Interface.'.
ENDMETHOD.
ENDCLASS.
CLASS context DEFINITION.
PUBLIC SECTION.
METHODS: constructor IMPORTING io_instance TYPE REF TO strategy
, context_interface.
PRIVATE SECTION.
DATA: mstrategy TYPE REF TO strategy.
ENDCLASS.
CLASS context IMPLEMENTATION.
METHOD constructor.
mstrategy = io_instance.
ENDMETHOD.
METHOD context_interface.
me->mstrategy->algorithm( ).
ENDMETHOD.
ENDCLASS.
CLASS mainapp DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: main.
ENDCLASS.
CLASS mainapp IMPLEMENTATION.
METHOD main.
DATA: o_context TYPE REF TO context.
DATA: o_strategy TYPE REF TO strategy.
CREATE OBJECT o_strategy TYPE concrete_strategya.
CREATE OBJECT o_context EXPORTING io_instance = o_strategy.
o_context->context_interface( ).
CREATE OBJECT o_strategy TYPE concrete_strategyb.
CREATE OBJECT o_context EXPORTING io_instance = o_strategy.
o_context->context_interface( ).
CREATE OBJECT o_strategy TYPE concrete_strategyc.
CREATE OBJECT o_context EXPORTING io_instance = o_strategy.
o_context->context_interface( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
mainapp=>main( ).