测试程序如下:
REPORT ZBOBO_DP_004_RE .
*Factory method pattern used interface and class
include zbobo_dp_004_if_cl.
*This data used to create two type of concrete creator
data:
ny_ref type ref to pizzastore,
chi_ref type ref to pizzastore.
*The different pizza have the same interface
data:
pz_ref type ref to pizza.
start-of-selection.
* Create two different pizzastore
create object ny_ref type ny. "For NY
create object chi_ref type chi."For Chi
* Book NY store's pizza
call method ny_ref->orderpizza
exporting pz_name1 = 'cheese'
receiving pz = pz_ref.
* Get the pizza's name
data: ls type string.
call method pz_ref->getname
receiving na = ls.
write: / 'Ethan ordered a:',ls.
skip.
* Book Chi store's pizza
call method chi_ref->orderpizza
exporting pz_name1 = 'cheese'
receiving pz = pz_ref.
* Get the pizza's name
call method pz_ref->getname
receiving na = ls.
write: / 'Joel ordered a:',ls.
*Factory method pattern used interface and class
include zbobo_dp_004_if_cl.
*This data used to create two type of concrete creator
data:
ny_ref type ref to pizzastore,
chi_ref type ref to pizzastore.
*The different pizza have the same interface
data:
pz_ref type ref to pizza.
start-of-selection.
* Create two different pizzastore
create object ny_ref type ny. "For NY
create object chi_ref type chi."For Chi
* Book NY store's pizza
call method ny_ref->orderpizza
exporting pz_name1 = 'cheese'
receiving pz = pz_ref.
* Get the pizza's name
data: ls type string.
call method pz_ref->getname
receiving na = ls.
write: / 'Ethan ordered a:',ls.
skip.
* Book Chi store's pizza
call method chi_ref->orderpizza
exporting pz_name1 = 'cheese'
receiving pz = pz_ref.
* Get the pizza's name
call method pz_ref->getname
receiving na = ls.
write: / 'Joel ordered a:',ls.