Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
110
tasks_gen/train/G1045/faulty/m0_cinema_pricer.clas.abap
Normal file
110
tasks_gen/train/G1045/faulty/m0_cinema_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}cinema_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_cinema_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_late_surcharge TYPE {{p}}if_cinema_price=>ty_amount VALUE '1.50',
|
||||
c_late_hour TYPE i VALUE 20,
|
||||
c_group_limit TYPE i VALUE 6,
|
||||
c_group_percent TYPE i VALUE 10,
|
||||
c_loyalty_pct TYPE i VALUE 5,
|
||||
c_max_tickets TYPE i VALUE 20,
|
||||
c_max_hour TYPE i VALUE 23.
|
||||
|
||||
METHODS is_known_screen
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS is_known_visitor
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS base_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_percent) TYPE i.
|
||||
METHODS ticket_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
iv_show_hour TYPE i
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cinema_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_cinema_price~price.
|
||||
IF is_known_screen( iv_screen ) = abap_true.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-screen.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF is_known_visitor( iv_visitor ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-visitor.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_quantity < 1 OR iv_quantity > c_max_tickets.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-quantity.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_show_hour < 0 OR iv_show_hour > c_max_hour.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-hour.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_total TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
lv_total = ticket_price( iv_screen = iv_screen
|
||||
iv_visitor = iv_visitor
|
||||
iv_show_hour = iv_show_hour ) * iv_quantity.
|
||||
IF iv_quantity >= c_group_limit.
|
||||
lv_total = lv_total * ( 100 - c_group_percent ) / 100.
|
||||
ENDIF.
|
||||
IF iv_loyalty = abap_true.
|
||||
lv_total = lv_total * ( 100 - c_loyalty_pct ) / 100.
|
||||
ENDIF.
|
||||
|
||||
rs_result-price = round( val = lv_total dec = 2 ).
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_screen.
|
||||
rv_known = xsdbool( iv_screen = {{p}}if_cinema_price=>c_screen-standard
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-three_d
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-large ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_visitor.
|
||||
rv_known = xsdbool( iv_visitor = {{p}}if_cinema_price=>c_visitor-adult
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-child
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-senior ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_price.
|
||||
CASE iv_screen.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-standard.
|
||||
rv_price = '9.50'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-three_d.
|
||||
rv_price = '12.00'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-large.
|
||||
rv_price = '15.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount_percent.
|
||||
CASE iv_visitor.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-child.
|
||||
rv_percent = 30.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-senior.
|
||||
rv_percent = 40.
|
||||
WHEN OTHERS.
|
||||
rv_percent = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ticket_price.
|
||||
rv_price = base_price( iv_screen ).
|
||||
rv_price = rv_price * ( 100 - discount_percent( iv_visitor ) ) / 100.
|
||||
IF iv_show_hour >= c_late_hour.
|
||||
rv_price = rv_price + c_late_surcharge.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
110
tasks_gen/train/G1045/faulty/m1_cinema_pricer.clas.abap
Normal file
110
tasks_gen/train/G1045/faulty/m1_cinema_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}cinema_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_cinema_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_late_surcharge TYPE {{p}}if_cinema_price=>ty_amount VALUE '1.50',
|
||||
c_late_hour TYPE i VALUE 20,
|
||||
c_group_limit TYPE i VALUE 6,
|
||||
c_group_percent TYPE i VALUE 10,
|
||||
c_loyalty_pct TYPE i VALUE 5,
|
||||
c_max_tickets TYPE i VALUE 20,
|
||||
c_max_hour TYPE i VALUE 23.
|
||||
|
||||
METHODS is_known_screen
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS is_known_visitor
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS base_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_percent) TYPE i.
|
||||
METHODS ticket_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
iv_show_hour TYPE i
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cinema_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_cinema_price~price.
|
||||
IF is_known_screen( iv_screen ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-screen.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF is_known_visitor( iv_visitor ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-visitor.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_quantity < 1 OR iv_quantity > c_max_tickets.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-quantity.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_show_hour < 0 OR iv_show_hour > c_max_hour.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-hour.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_total TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
lv_total = ticket_price( iv_screen = iv_screen
|
||||
iv_visitor = iv_visitor
|
||||
iv_show_hour = iv_show_hour ) / iv_quantity.
|
||||
IF iv_quantity >= c_group_limit.
|
||||
lv_total = lv_total * ( 100 - c_group_percent ) / 100.
|
||||
ENDIF.
|
||||
IF iv_loyalty = abap_true.
|
||||
lv_total = lv_total * ( 100 - c_loyalty_pct ) / 100.
|
||||
ENDIF.
|
||||
|
||||
rs_result-price = round( val = lv_total dec = 2 ).
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_screen.
|
||||
rv_known = xsdbool( iv_screen = {{p}}if_cinema_price=>c_screen-standard
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-three_d
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-large ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_visitor.
|
||||
rv_known = xsdbool( iv_visitor = {{p}}if_cinema_price=>c_visitor-adult
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-child
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-senior ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_price.
|
||||
CASE iv_screen.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-standard.
|
||||
rv_price = '9.50'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-three_d.
|
||||
rv_price = '12.00'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-large.
|
||||
rv_price = '15.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount_percent.
|
||||
CASE iv_visitor.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-child.
|
||||
rv_percent = 30.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-senior.
|
||||
rv_percent = 40.
|
||||
WHEN OTHERS.
|
||||
rv_percent = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ticket_price.
|
||||
rv_price = base_price( iv_screen ).
|
||||
rv_price = rv_price * ( 100 - discount_percent( iv_visitor ) ) / 100.
|
||||
IF iv_show_hour >= c_late_hour.
|
||||
rv_price = rv_price + c_late_surcharge.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
110
tasks_gen/train/G1045/faulty/m2_cinema_pricer.clas.abap
Normal file
110
tasks_gen/train/G1045/faulty/m2_cinema_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}cinema_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_cinema_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_late_surcharge TYPE {{p}}if_cinema_price=>ty_amount VALUE '1.50',
|
||||
c_late_hour TYPE i VALUE 20,
|
||||
c_group_limit TYPE i VALUE 6,
|
||||
c_group_percent TYPE i VALUE 10,
|
||||
c_loyalty_pct TYPE i VALUE 5,
|
||||
c_max_tickets TYPE i VALUE 20,
|
||||
c_max_hour TYPE i VALUE 23.
|
||||
|
||||
METHODS is_known_screen
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS is_known_visitor
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS base_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_percent) TYPE i.
|
||||
METHODS ticket_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
iv_show_hour TYPE i
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cinema_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_cinema_price~price.
|
||||
IF is_known_screen( iv_screen ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-screen.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF is_known_visitor( iv_visitor ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-visitor.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_quantity < 1 OR iv_quantity > c_max_tickets.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-quantity.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_show_hour < 0 OR iv_show_hour > c_max_hour.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-hour.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_total TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
lv_total = ticket_price( iv_screen = iv_screen
|
||||
iv_visitor = iv_visitor
|
||||
iv_show_hour = iv_show_hour ) * iv_quantity.
|
||||
IF iv_quantity >= c_group_limit.
|
||||
lv_total = lv_total * ( 101 - c_group_percent ) / 100.
|
||||
ENDIF.
|
||||
IF iv_loyalty = abap_true.
|
||||
lv_total = lv_total * ( 100 - c_loyalty_pct ) / 100.
|
||||
ENDIF.
|
||||
|
||||
rs_result-price = round( val = lv_total dec = 2 ).
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_screen.
|
||||
rv_known = xsdbool( iv_screen = {{p}}if_cinema_price=>c_screen-standard
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-three_d
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-large ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_visitor.
|
||||
rv_known = xsdbool( iv_visitor = {{p}}if_cinema_price=>c_visitor-adult
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-child
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-senior ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_price.
|
||||
CASE iv_screen.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-standard.
|
||||
rv_price = '9.50'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-three_d.
|
||||
rv_price = '12.00'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-large.
|
||||
rv_price = '15.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount_percent.
|
||||
CASE iv_visitor.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-child.
|
||||
rv_percent = 30.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-senior.
|
||||
rv_percent = 40.
|
||||
WHEN OTHERS.
|
||||
rv_percent = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ticket_price.
|
||||
rv_price = base_price( iv_screen ).
|
||||
rv_price = rv_price * ( 100 - discount_percent( iv_visitor ) ) / 100.
|
||||
IF iv_show_hour >= c_late_hour.
|
||||
rv_price = rv_price + c_late_surcharge.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
110
tasks_gen/train/G1045/faulty/m3_cinema_pricer.clas.abap
Normal file
110
tasks_gen/train/G1045/faulty/m3_cinema_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}cinema_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_cinema_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_late_surcharge TYPE {{p}}if_cinema_price=>ty_amount VALUE '1.50',
|
||||
c_late_hour TYPE i VALUE 20,
|
||||
c_group_limit TYPE i VALUE 6,
|
||||
c_group_percent TYPE i VALUE 10,
|
||||
c_loyalty_pct TYPE i VALUE 5,
|
||||
c_max_tickets TYPE i VALUE 20,
|
||||
c_max_hour TYPE i VALUE 23.
|
||||
|
||||
METHODS is_known_screen
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS is_known_visitor
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS base_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_percent) TYPE i.
|
||||
METHODS ticket_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
iv_show_hour TYPE i
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cinema_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_cinema_price~price.
|
||||
IF is_known_screen( iv_screen ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-screen.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF is_known_visitor( iv_visitor ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-visitor.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_quantity < 1 OR iv_quantity > c_max_tickets.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-quantity.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_show_hour < 0 OR iv_show_hour > c_max_hour.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-hour.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_total TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
lv_total = ticket_price( iv_screen = iv_screen
|
||||
iv_visitor = iv_visitor
|
||||
iv_show_hour = iv_show_hour ) * iv_quantity.
|
||||
IF iv_quantity >= c_group_limit.
|
||||
lv_total = lv_total * ( 100 - c_group_percent ) / 100.
|
||||
ENDIF.
|
||||
IF iv_loyalty = abap_true.
|
||||
lv_total = lv_total * ( 100 - c_loyalty_pct ) / 100.
|
||||
ENDIF.
|
||||
|
||||
rs_result-price = round( val = lv_total dec = 2 ).
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_screen.
|
||||
rv_known = xsdbool( iv_screen = {{p}}if_cinema_price=>c_screen-standard
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-three_d
|
||||
OR iv_screen <> {{p}}if_cinema_price=>c_screen-large ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_visitor.
|
||||
rv_known = xsdbool( iv_visitor = {{p}}if_cinema_price=>c_visitor-adult
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-child
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-senior ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_price.
|
||||
CASE iv_screen.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-standard.
|
||||
rv_price = '9.50'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-three_d.
|
||||
rv_price = '12.00'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-large.
|
||||
rv_price = '15.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount_percent.
|
||||
CASE iv_visitor.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-child.
|
||||
rv_percent = 30.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-senior.
|
||||
rv_percent = 40.
|
||||
WHEN OTHERS.
|
||||
rv_percent = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ticket_price.
|
||||
rv_price = base_price( iv_screen ).
|
||||
rv_price = rv_price * ( 100 - discount_percent( iv_visitor ) ) / 100.
|
||||
IF iv_show_hour >= c_late_hour.
|
||||
rv_price = rv_price + c_late_surcharge.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
110
tasks_gen/train/G1045/faulty/m4_cinema_pricer.clas.abap
Normal file
110
tasks_gen/train/G1045/faulty/m4_cinema_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}cinema_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_cinema_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_late_surcharge TYPE {{p}}if_cinema_price=>ty_amount VALUE '1.50',
|
||||
c_late_hour TYPE i VALUE 20,
|
||||
c_group_limit TYPE i VALUE 6,
|
||||
c_group_percent TYPE i VALUE 10,
|
||||
c_loyalty_pct TYPE i VALUE 5,
|
||||
c_max_tickets TYPE i VALUE 20,
|
||||
c_max_hour TYPE i VALUE 23.
|
||||
|
||||
METHODS is_known_screen
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS is_known_visitor
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS base_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_percent) TYPE i.
|
||||
METHODS ticket_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
iv_show_hour TYPE i
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cinema_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_cinema_price~price.
|
||||
IF is_known_screen( iv_screen ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-screen.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF is_known_visitor( iv_visitor ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-visitor.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_quantity < 1 OR iv_quantity > c_max_tickets.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-quantity.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_show_hour < 0 OR iv_show_hour > c_max_hour.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-hour.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_total TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
lv_total = ticket_price( iv_screen = iv_screen
|
||||
iv_visitor = iv_visitor
|
||||
iv_show_hour = iv_show_hour ) * iv_quantity.
|
||||
IF iv_quantity >= c_group_limit.
|
||||
lv_total = lv_total * ( 100 - c_group_percent ) / 100.
|
||||
ENDIF.
|
||||
IF iv_loyalty = abap_true.
|
||||
lv_total = lv_total * ( 100 - c_loyalty_pct ) / 100.
|
||||
ENDIF.
|
||||
|
||||
rs_result-price = round( val = lv_total dec = 2 ).
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_screen.
|
||||
rv_known = xsdbool( iv_screen = {{p}}if_cinema_price=>c_screen-standard
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-three_d
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-large ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_visitor.
|
||||
rv_known = xsdbool( iv_visitor = {{p}}if_cinema_price=>c_visitor-adult
|
||||
AND iv_visitor = {{p}}if_cinema_price=>c_visitor-child
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-senior ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_price.
|
||||
CASE iv_screen.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-standard.
|
||||
rv_price = '9.50'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-three_d.
|
||||
rv_price = '12.00'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-large.
|
||||
rv_price = '15.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount_percent.
|
||||
CASE iv_visitor.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-child.
|
||||
rv_percent = 30.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-senior.
|
||||
rv_percent = 40.
|
||||
WHEN OTHERS.
|
||||
rv_percent = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ticket_price.
|
||||
rv_price = base_price( iv_screen ).
|
||||
rv_price = rv_price * ( 100 - discount_percent( iv_visitor ) ) / 100.
|
||||
IF iv_show_hour >= c_late_hour.
|
||||
rv_price = rv_price + c_late_surcharge.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
19
tasks_gen/train/G1045/generation.json
Normal file
19
tasks_gen/train/G1045/generation.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"id": "G1045",
|
||||
"pool": "train",
|
||||
"object_type": "CLAS",
|
||||
"category": "F",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
217
tasks_gen/train/G1045/hidden/t21_hidden.clas.abap
Normal file
217
tasks_gen/train/G1045/hidden/t21_hidden.clas.abap
Normal file
@@ -0,0 +1,217 @@
|
||||
CLASS {{p}}t21_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_cinema_price.
|
||||
|
||||
METHODS setup.
|
||||
METHODS screen_prices FOR TESTING.
|
||||
METHODS visitor_discounts FOR TESTING.
|
||||
METHODS late_show_surcharge FOR TESTING.
|
||||
METHODS group_discount FOR TESTING.
|
||||
METHODS loyalty_discount FOR TESTING.
|
||||
METHODS rounds_to_cents FOR TESTING.
|
||||
METHODS invalid_screen FOR TESTING.
|
||||
METHODS invalid_visitor FOR TESTING.
|
||||
METHODS invalid_quantity FOR TESTING.
|
||||
METHODS invalid_hour FOR TESTING.
|
||||
METHODS reason_order FOR TESTING.
|
||||
|
||||
METHODS result_of
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
iv_quantity TYPE i
|
||||
iv_hour TYPE i
|
||||
iv_loyalty TYPE abap_bool
|
||||
RETURNING VALUE(rs_result) TYPE {{p}}if_cinema_price=>ty_result.
|
||||
METHODS amount
|
||||
IMPORTING iv_text TYPE string
|
||||
RETURNING VALUE(rv_amount) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t21_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}cinema_pricer( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD screen_prices.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '9.50' )
|
||||
act = ls_result-price
|
||||
msg = 'standard' ).
|
||||
ls_result = result_of( iv_screen = 'T' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '12.00' )
|
||||
act = ls_result-price
|
||||
msg = 'three-d' ).
|
||||
ls_result = result_of( iv_screen = 'L' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '15.00' )
|
||||
act = ls_result-price
|
||||
msg = 'large' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD visitor_discounts.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'C'
|
||||
iv_quantity = 1 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '6.65' )
|
||||
act = ls_result-price
|
||||
msg = 'child' ).
|
||||
ls_result = result_of( iv_screen = 'S' iv_visitor = 'S'
|
||||
iv_quantity = 1 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '5.70' )
|
||||
act = ls_result-price
|
||||
msg = 'senior' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD late_show_surcharge.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 19
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '9.50' )
|
||||
act = ls_result-price
|
||||
msg = 'before 20' ).
|
||||
ls_result = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 20
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '11.00' )
|
||||
act = ls_result-price
|
||||
msg = 'from 20' ).
|
||||
ls_result = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 23
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '11.00' )
|
||||
act = ls_result-price
|
||||
msg = 'late' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD group_discount.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 5 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '47.50' )
|
||||
act = ls_result-price
|
||||
msg = 'below limit' ).
|
||||
ls_result = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 6 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '51.30' )
|
||||
act = ls_result-price
|
||||
msg = 'from 6' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD loyalty_discount.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 2 iv_hour = 18
|
||||
iv_loyalty = abap_true ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '18.05' )
|
||||
act = ls_result-price
|
||||
msg = 'loyalty' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rounds_to_cents.
|
||||
DATA(ls_result) = result_of( iv_screen = 'T' iv_visitor = 'C'
|
||||
iv_quantity = 6 iv_hour = 21
|
||||
iv_loyalty = abap_true ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '50.79' )
|
||||
act = ls_result-price
|
||||
msg = 'rounded' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_screen.
|
||||
DATA(ls_result) = result_of( iv_screen = 'X' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-screen
|
||||
act = ls_result-reason ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '0.00' )
|
||||
act = ls_result-price ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_visitor.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'X'
|
||||
iv_quantity = 1 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-visitor
|
||||
act = ls_result-reason ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '0.00' )
|
||||
act = ls_result-price ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_quantity.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 0 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-quantity
|
||||
act = ls_result-reason
|
||||
msg = 'zero' ).
|
||||
ls_result = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 21 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-quantity
|
||||
act = ls_result-reason
|
||||
msg = 'too many' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_hour.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 24
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-hour
|
||||
act = ls_result-reason
|
||||
msg = '24' ).
|
||||
ls_result = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = -1
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-hour
|
||||
act = ls_result-reason
|
||||
msg = 'negative' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD reason_order.
|
||||
DATA(ls_result) = result_of( iv_screen = 'X' iv_visitor = 'X'
|
||||
iv_quantity = 0 iv_hour = 99
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-screen
|
||||
act = ls_result-reason
|
||||
msg = 'screen first' ).
|
||||
ls_result = result_of( iv_screen = 'S' iv_visitor = 'X'
|
||||
iv_quantity = 0 iv_hour = 99
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-visitor
|
||||
act = ls_result-reason
|
||||
msg = 'visitor second' ).
|
||||
ls_result = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 0 iv_hour = 99
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-quantity
|
||||
act = ls_result-reason
|
||||
msg = 'quantity third' ).
|
||||
ls_result = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 99
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-hour
|
||||
act = ls_result-reason
|
||||
msg = 'hour fourth' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD result_of.
|
||||
rs_result = mo_cut->price( iv_screen = iv_screen
|
||||
iv_visitor = iv_visitor
|
||||
iv_quantity = iv_quantity
|
||||
iv_show_hour = iv_hour
|
||||
iv_loyalty = iv_loyalty ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD amount.
|
||||
rv_amount = iv_text.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
77
tasks_gen/train/G1045/mutation.json
Normal file
77
tasks_gen/train/G1045/mutation.json
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"task": "G1045",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}CINEMA_PRICER",
|
||||
"mutant": "line 37: abap_false -> abap_true (bool)",
|
||||
"status": "killed",
|
||||
"hidden": "0/11",
|
||||
"failed_tests": [
|
||||
"GROUP_DISCOUNT",
|
||||
"INVALID_HOUR",
|
||||
"INVALID_QUANTITY",
|
||||
"INVALID_SCREEN",
|
||||
"INVALID_VISITOR",
|
||||
"LATE_SHOW_SURCHARGE",
|
||||
"LOYALTY_DISCOUNT",
|
||||
"REASON_ORDER",
|
||||
"ROUNDS_TO_CENTS",
|
||||
"SCREEN_PRICES",
|
||||
"VISITOR_DISCOUNTS"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CINEMA_PRICER",
|
||||
"mutant": "line 57: * -> / (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "8/11",
|
||||
"failed_tests": [
|
||||
"GROUP_DISCOUNT",
|
||||
"LOYALTY_DISCOUNT",
|
||||
"ROUNDS_TO_CENTS"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CINEMA_PRICER",
|
||||
"mutant": "line 59: 100 -> 101 (const)",
|
||||
"status": "killed",
|
||||
"hidden": "9/11",
|
||||
"failed_tests": [
|
||||
"GROUP_DISCOUNT",
|
||||
"ROUNDS_TO_CENTS"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CINEMA_PRICER",
|
||||
"mutant": "line 72: = -> <> (eq)",
|
||||
"status": "killed",
|
||||
"hidden": "8/11",
|
||||
"failed_tests": [
|
||||
"INVALID_SCREEN",
|
||||
"REASON_ORDER",
|
||||
"SCREEN_PRICES"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CINEMA_PRICER",
|
||||
"mutant": "line 77: OR -> AND (logic)",
|
||||
"status": "killed",
|
||||
"hidden": "2/11",
|
||||
"failed_tests": [
|
||||
"GROUP_DISCOUNT",
|
||||
"INVALID_HOUR",
|
||||
"INVALID_QUANTITY",
|
||||
"LATE_SHOW_SURCHARGE",
|
||||
"LOYALTY_DISCOUNT",
|
||||
"REASON_ORDER",
|
||||
"ROUNDS_TO_CENTS",
|
||||
"SCREEN_PRICES",
|
||||
"VISITOR_DISCOUNTS"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
110
tasks_gen/train/G1045/reference/cinema_pricer.clas.abap
Normal file
110
tasks_gen/train/G1045/reference/cinema_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}cinema_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_cinema_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_late_surcharge TYPE {{p}}if_cinema_price=>ty_amount VALUE '1.50',
|
||||
c_late_hour TYPE i VALUE 20,
|
||||
c_group_limit TYPE i VALUE 6,
|
||||
c_group_percent TYPE i VALUE 10,
|
||||
c_loyalty_pct TYPE i VALUE 5,
|
||||
c_max_tickets TYPE i VALUE 20,
|
||||
c_max_hour TYPE i VALUE 23.
|
||||
|
||||
METHODS is_known_screen
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS is_known_visitor
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_known) TYPE abap_bool.
|
||||
METHODS base_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
RETURNING VALUE(rv_percent) TYPE i.
|
||||
METHODS ticket_price
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
iv_show_hour TYPE i
|
||||
RETURNING VALUE(rv_price) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cinema_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_cinema_price~price.
|
||||
IF is_known_screen( iv_screen ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-screen.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF is_known_visitor( iv_visitor ) = abap_false.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-visitor.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_quantity < 1 OR iv_quantity > c_max_tickets.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-quantity.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_show_hour < 0 OR iv_show_hour > c_max_hour.
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-hour.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_total TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
lv_total = ticket_price( iv_screen = iv_screen
|
||||
iv_visitor = iv_visitor
|
||||
iv_show_hour = iv_show_hour ) * iv_quantity.
|
||||
IF iv_quantity >= c_group_limit.
|
||||
lv_total = lv_total * ( 100 - c_group_percent ) / 100.
|
||||
ENDIF.
|
||||
IF iv_loyalty = abap_true.
|
||||
lv_total = lv_total * ( 100 - c_loyalty_pct ) / 100.
|
||||
ENDIF.
|
||||
|
||||
rs_result-price = round( val = lv_total dec = 2 ).
|
||||
rs_result-reason = {{p}}if_cinema_price=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_screen.
|
||||
rv_known = xsdbool( iv_screen = {{p}}if_cinema_price=>c_screen-standard
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-three_d
|
||||
OR iv_screen = {{p}}if_cinema_price=>c_screen-large ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_known_visitor.
|
||||
rv_known = xsdbool( iv_visitor = {{p}}if_cinema_price=>c_visitor-adult
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-child
|
||||
OR iv_visitor = {{p}}if_cinema_price=>c_visitor-senior ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_price.
|
||||
CASE iv_screen.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-standard.
|
||||
rv_price = '9.50'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-three_d.
|
||||
rv_price = '12.00'.
|
||||
WHEN {{p}}if_cinema_price=>c_screen-large.
|
||||
rv_price = '15.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount_percent.
|
||||
CASE iv_visitor.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-child.
|
||||
rv_percent = 30.
|
||||
WHEN {{p}}if_cinema_price=>c_visitor-senior.
|
||||
rv_percent = 40.
|
||||
WHEN OTHERS.
|
||||
rv_percent = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ticket_price.
|
||||
rv_price = base_price( iv_screen ).
|
||||
rv_price = rv_price * ( 100 - discount_percent( iv_visitor ) ) / 100.
|
||||
IF iv_show_hour >= c_late_hour.
|
||||
rv_price = rv_price + c_late_surcharge.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,95 @@
|
||||
CLASS ltc_cinema_pricer DEFINITION FINAL FOR TESTING
|
||||
DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_cinema_price.
|
||||
|
||||
METHODS setup.
|
||||
METHODS standard_adult FOR TESTING.
|
||||
METHODS child_ticket FOR TESTING.
|
||||
METHODS late_show FOR TESTING.
|
||||
METHODS group_and_loyalty FOR TESTING.
|
||||
METHODS invalid_screen FOR TESTING.
|
||||
METHODS invalid_quantity FOR TESTING.
|
||||
|
||||
METHODS result_of
|
||||
IMPORTING iv_screen TYPE {{p}}if_cinema_price=>ty_screen
|
||||
iv_visitor TYPE {{p}}if_cinema_price=>ty_visitor
|
||||
iv_quantity TYPE i
|
||||
iv_hour TYPE i
|
||||
iv_loyalty TYPE abap_bool
|
||||
RETURNING VALUE(rs_result) TYPE {{p}}if_cinema_price=>ty_result.
|
||||
METHODS amount
|
||||
IMPORTING iv_text TYPE string
|
||||
RETURNING VALUE(rv_amount) TYPE {{p}}if_cinema_price=>ty_amount.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_cinema_pricer IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}cinema_pricer( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD standard_adult.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '9.50' )
|
||||
act = ls_result-price ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD child_ticket.
|
||||
DATA(ls_result) = result_of( iv_screen = 'T' iv_visitor = 'C'
|
||||
iv_quantity = 1 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '8.40' )
|
||||
act = ls_result-price ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD late_show.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 20
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '11.00' )
|
||||
act = ls_result-price ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD group_and_loyalty.
|
||||
DATA(ls_result) = result_of( iv_screen = 'T' iv_visitor = 'C'
|
||||
iv_quantity = 6 iv_hour = 21
|
||||
iv_loyalty = abap_true ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '50.79' )
|
||||
act = ls_result-price ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_screen.
|
||||
DATA(ls_result) = result_of( iv_screen = 'X' iv_visitor = 'A'
|
||||
iv_quantity = 1 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-screen
|
||||
act = ls_result-reason ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = amount( '0.00' )
|
||||
act = ls_result-price ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_quantity.
|
||||
DATA(ls_result) = result_of( iv_screen = 'S' iv_visitor = 'A'
|
||||
iv_quantity = 0 iv_hour = 18
|
||||
iv_loyalty = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cinema_price=>c_reason-quantity
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD result_of.
|
||||
rs_result = mo_cut->price( iv_screen = iv_screen
|
||||
iv_visitor = iv_visitor
|
||||
iv_quantity = iv_quantity
|
||||
iv_show_hour = iv_hour
|
||||
iv_loyalty = iv_loyalty ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD amount.
|
||||
rv_amount = iv_text.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
42
tasks_gen/train/G1045/seed/if_cinema_price.intf.abap
Normal file
42
tasks_gen/train/G1045/seed/if_cinema_price.intf.abap
Normal file
@@ -0,0 +1,42 @@
|
||||
INTERFACE {{p}}if_cinema_price PUBLIC.
|
||||
TYPES ty_screen TYPE c LENGTH 1.
|
||||
TYPES ty_visitor TYPE c LENGTH 1.
|
||||
TYPES ty_reason TYPE c LENGTH 12.
|
||||
TYPES ty_amount TYPE p LENGTH 7 DECIMALS 2.
|
||||
|
||||
TYPES: BEGIN OF ty_result,
|
||||
price TYPE ty_amount,
|
||||
reason TYPE ty_reason,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_screen,
|
||||
standard TYPE ty_screen VALUE 'S',
|
||||
three_d TYPE ty_screen VALUE 'T',
|
||||
large TYPE ty_screen VALUE 'L',
|
||||
END OF c_screen.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_visitor,
|
||||
adult TYPE ty_visitor VALUE 'A',
|
||||
child TYPE ty_visitor VALUE 'C',
|
||||
senior TYPE ty_visitor VALUE 'S',
|
||||
END OF c_visitor.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'OK',
|
||||
screen TYPE ty_reason VALUE 'SCREEN',
|
||||
visitor TYPE ty_reason VALUE 'VISITOR',
|
||||
quantity TYPE ty_reason VALUE 'QUANTITY',
|
||||
hour TYPE ty_reason VALUE 'HOUR',
|
||||
END OF c_reason.
|
||||
|
||||
METHODS price
|
||||
IMPORTING iv_screen TYPE ty_screen
|
||||
iv_visitor TYPE ty_visitor
|
||||
iv_quantity TYPE i
|
||||
iv_show_hour TYPE i
|
||||
iv_loyalty TYPE abap_bool
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
ENDINTERFACE.
|
||||
62
tasks_gen/train/G1045/spec.md
Normal file
62
tasks_gen/train/G1045/spec.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# 1. Goal
|
||||
A cinema multiplex prices ticket orders. The checkout program calls one class
|
||||
for each order. The class calculates the total price of the order and returns a
|
||||
reason code.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The interface {{P}}IF_CINEMA_PRICE exists in package $TMP. It is active.
|
||||
- The interface contains the exact signature of the calculation, the result
|
||||
structure and the reason codes. Read the interface before you start.
|
||||
|
||||
# 4. Contract
|
||||
- Create the class {{P}}CINEMA_PRICER in package $TMP.
|
||||
- The class is public and final. It has a public constructor without parameters.
|
||||
- The class implements {{P}}IF_CINEMA_PRICE.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
The caller gives five values: the screen category, the visitor category, the
|
||||
number of tickets, the hour when the show starts, and the loyalty card flag.
|
||||
The calculation returns the total price and a reason code.
|
||||
|
||||
Screen categories and the base price of one ticket:
|
||||
- S (standard): 9.50
|
||||
- T (three-dimensional): 12.00
|
||||
- L (large format): 15.00
|
||||
|
||||
Visitor categories and the discount on the base price:
|
||||
- A (adult): 0 percent
|
||||
- C (child): 30 percent
|
||||
- S (senior): 40 percent
|
||||
|
||||
Check the input in this sequence. Stop at the first invalid value. Return a
|
||||
price of zero and the reason of this value.
|
||||
1. The screen category must be S, T or L. Else return the reason SCREEN.
|
||||
2. The visitor category must be A, C or S. Else return the reason VISITOR.
|
||||
3. The number of tickets must be 1 to 20. Else return the reason QUANTITY.
|
||||
4. The hour must be 0 to 23. Else return the reason HOUR.
|
||||
|
||||
Calculate the price in this sequence:
|
||||
5. Take the base price of the screen category.
|
||||
6. Reduce the price of one ticket by the visitor discount.
|
||||
7. If the hour is 20 or later, add a late-show surcharge of 1.50 to the price
|
||||
of one ticket.
|
||||
8. Multiply the price of one ticket by the number of tickets.
|
||||
9. If the number of tickets is 6 or more, reduce the total by 10 percent.
|
||||
10. If the loyalty card flag is true, reduce the total by 5 percent.
|
||||
11. Round the total to two decimal places.
|
||||
12. Return the total and the reason OK.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 8.16.
|
||||
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
||||
variables. No comment that restates the code.
|
||||
- Out of scope: do not change {{P}}IF_CINEMA_PRICE.
|
||||
|
||||
# 7. Acceptance
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
51
tasks_gen/train/G1045/task.json
Normal file
51
tasks_gen/train/G1045/task.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"id": "G1045",
|
||||
"category": "F",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 80,
|
||||
"max_activations": 20
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_CINEMA_PRICE",
|
||||
"file": "seed/if_cinema_price.intf.abap",
|
||||
"description": "Ticket price interface. It holds the calculation signature, the result structure and the reason codes. The spec does not show the signature. The model must read the interface."
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CINEMA_PRICER",
|
||||
"implements": "{{P}}IF_CINEMA_PRICE"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}IF_CINEMA_PRICE"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T21_HIDDEN",
|
||||
"file": "hidden/t21_hidden.clas.abap",
|
||||
"description": "Hidden tests for the cinema ticket price"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CINEMA_PRICER",
|
||||
"file": "reference/cinema_pricer.clas.abap",
|
||||
"description": "Cinema ticket price calculation",
|
||||
"testclasses_file": "reference/cinema_pricer.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"db_operation_in_loop"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user