Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
126
tasks_gen/train/G1050/faulty/m0_tailor_pricer.clas.abap
Normal file
126
tasks_gen/train/G1050/faulty/m0_tailor_pricer.clas.abap
Normal file
@@ -0,0 +1,126 @@
|
||||
CLASS {{p}}tailor_pricer DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
||||
TYPES ty_garment TYPE c LENGTH 10.
|
||||
TYPES ty_service TYPE c LENGTH 10.
|
||||
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
METHODS calculate_price
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
iv_service TYPE ty_service
|
||||
iv_quantity TYPE i
|
||||
iv_express TYPE abap_bool
|
||||
RETURNING VALUE(rv_price) TYPE ty_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
|
||||
CONSTANTS:
|
||||
c_express_fee TYPE ty_price VALUE '6.00',
|
||||
c_minimum_price TYPE ty_price VALUE '15.00',
|
||||
c_discount_low TYPE ty_price VALUE '10.00',
|
||||
c_discount_high TYPE ty_price VALUE '20.00',
|
||||
c_qty_low TYPE i VALUE 3,
|
||||
c_qty_high TYPE i VALUE 5,
|
||||
c_percent_base TYPE i VALUE 100.
|
||||
|
||||
METHODS service_base
|
||||
IMPORTING iv_service TYPE ty_service
|
||||
RETURNING VALUE(rv_base) TYPE ty_price.
|
||||
METHODS garment_factor
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
RETURNING VALUE(rv_factor) TYPE ty_price.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_quantity TYPE i
|
||||
RETURNING VALUE(rv_percent) TYPE ty_price.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS {{p}}tailor_pricer IMPLEMENTATION.
|
||||
|
||||
METHOD calculate_price.
|
||||
|
||||
DATA lv_base TYPE ty_price.
|
||||
DATA lv_factor TYPE ty_price.
|
||||
DATA lv_unit TYPE ty_price.
|
||||
DATA lv_total TYPE ty_price.
|
||||
DATA lv_discount TYPE ty_price.
|
||||
|
||||
IF iv_quantity <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_base = service_base( iv_service ).
|
||||
lv_factor = garment_factor( iv_garment ).
|
||||
IF lv_base <= 0 AND lv_factor <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_unit = lv_base * lv_factor.
|
||||
IF iv_express = abap_true.
|
||||
lv_unit = lv_unit + c_express_fee.
|
||||
ENDIF.
|
||||
|
||||
lv_total = lv_unit * iv_quantity.
|
||||
lv_discount = discount_percent( iv_quantity ).
|
||||
lv_total = lv_total - lv_total * lv_discount / c_percent_base.
|
||||
|
||||
IF lv_total < c_minimum_price.
|
||||
rv_price = c_minimum_price.
|
||||
ELSE.
|
||||
rv_price = lv_total.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD service_base.
|
||||
CASE iv_service.
|
||||
WHEN 'HEM'.
|
||||
rv_base = '8.00'.
|
||||
WHEN 'TAKE_IN'.
|
||||
rv_base = '15.00'.
|
||||
WHEN 'ZIP'.
|
||||
rv_base = '12.00'.
|
||||
WHEN 'SLEEVE'.
|
||||
rv_base = '10.00'.
|
||||
WHEN 'LINING'.
|
||||
rv_base = '25.00'.
|
||||
WHEN OTHERS.
|
||||
rv_base = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD garment_factor.
|
||||
CASE iv_garment.
|
||||
WHEN 'TROUSERS'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'SKIRT'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'JACKET'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'DRESS'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'COAT'.
|
||||
rv_factor = '2.00'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD discount_percent.
|
||||
IF iv_quantity >= c_qty_high.
|
||||
rv_percent = c_discount_high.
|
||||
ELSEIF iv_quantity >= c_qty_low.
|
||||
rv_percent = c_discount_low.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
126
tasks_gen/train/G1050/faulty/m1_tailor_pricer.clas.abap
Normal file
126
tasks_gen/train/G1050/faulty/m1_tailor_pricer.clas.abap
Normal file
@@ -0,0 +1,126 @@
|
||||
CLASS {{p}}tailor_pricer DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
||||
TYPES ty_garment TYPE c LENGTH 10.
|
||||
TYPES ty_service TYPE c LENGTH 10.
|
||||
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
METHODS calculate_price
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
iv_service TYPE ty_service
|
||||
iv_quantity TYPE i
|
||||
iv_express TYPE abap_bool
|
||||
RETURNING VALUE(rv_price) TYPE ty_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
|
||||
CONSTANTS:
|
||||
c_express_fee TYPE ty_price VALUE '6.00',
|
||||
c_minimum_price TYPE ty_price VALUE '15.00',
|
||||
c_discount_low TYPE ty_price VALUE '10.00',
|
||||
c_discount_high TYPE ty_price VALUE '20.00',
|
||||
c_qty_low TYPE i VALUE 3,
|
||||
c_qty_high TYPE i VALUE 5,
|
||||
c_percent_base TYPE i VALUE 100.
|
||||
|
||||
METHODS service_base
|
||||
IMPORTING iv_service TYPE ty_service
|
||||
RETURNING VALUE(rv_base) TYPE ty_price.
|
||||
METHODS garment_factor
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
RETURNING VALUE(rv_factor) TYPE ty_price.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_quantity TYPE i
|
||||
RETURNING VALUE(rv_percent) TYPE ty_price.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS {{p}}tailor_pricer IMPLEMENTATION.
|
||||
|
||||
METHOD calculate_price.
|
||||
|
||||
DATA lv_base TYPE ty_price.
|
||||
DATA lv_factor TYPE ty_price.
|
||||
DATA lv_unit TYPE ty_price.
|
||||
DATA lv_total TYPE ty_price.
|
||||
DATA lv_discount TYPE ty_price.
|
||||
|
||||
IF iv_quantity <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_base = service_base( iv_service ).
|
||||
lv_factor = garment_factor( iv_garment ).
|
||||
IF lv_base <= 0 OR lv_factor <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_unit = lv_base * lv_factor.
|
||||
IF iv_express <> abap_true.
|
||||
lv_unit = lv_unit + c_express_fee.
|
||||
ENDIF.
|
||||
|
||||
lv_total = lv_unit * iv_quantity.
|
||||
lv_discount = discount_percent( iv_quantity ).
|
||||
lv_total = lv_total - lv_total * lv_discount / c_percent_base.
|
||||
|
||||
IF lv_total < c_minimum_price.
|
||||
rv_price = c_minimum_price.
|
||||
ELSE.
|
||||
rv_price = lv_total.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD service_base.
|
||||
CASE iv_service.
|
||||
WHEN 'HEM'.
|
||||
rv_base = '8.00'.
|
||||
WHEN 'TAKE_IN'.
|
||||
rv_base = '15.00'.
|
||||
WHEN 'ZIP'.
|
||||
rv_base = '12.00'.
|
||||
WHEN 'SLEEVE'.
|
||||
rv_base = '10.00'.
|
||||
WHEN 'LINING'.
|
||||
rv_base = '25.00'.
|
||||
WHEN OTHERS.
|
||||
rv_base = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD garment_factor.
|
||||
CASE iv_garment.
|
||||
WHEN 'TROUSERS'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'SKIRT'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'JACKET'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'DRESS'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'COAT'.
|
||||
rv_factor = '2.00'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD discount_percent.
|
||||
IF iv_quantity >= c_qty_high.
|
||||
rv_percent = c_discount_high.
|
||||
ELSEIF iv_quantity >= c_qty_low.
|
||||
rv_percent = c_discount_low.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
126
tasks_gen/train/G1050/faulty/m2_tailor_pricer.clas.abap
Normal file
126
tasks_gen/train/G1050/faulty/m2_tailor_pricer.clas.abap
Normal file
@@ -0,0 +1,126 @@
|
||||
CLASS {{p}}tailor_pricer DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
||||
TYPES ty_garment TYPE c LENGTH 10.
|
||||
TYPES ty_service TYPE c LENGTH 10.
|
||||
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
METHODS calculate_price
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
iv_service TYPE ty_service
|
||||
iv_quantity TYPE i
|
||||
iv_express TYPE abap_bool
|
||||
RETURNING VALUE(rv_price) TYPE ty_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
|
||||
CONSTANTS:
|
||||
c_express_fee TYPE ty_price VALUE '6.00',
|
||||
c_minimum_price TYPE ty_price VALUE '15.00',
|
||||
c_discount_low TYPE ty_price VALUE '10.00',
|
||||
c_discount_high TYPE ty_price VALUE '20.00',
|
||||
c_qty_low TYPE i VALUE 3,
|
||||
c_qty_high TYPE i VALUE 5,
|
||||
c_percent_base TYPE i VALUE 100.
|
||||
|
||||
METHODS service_base
|
||||
IMPORTING iv_service TYPE ty_service
|
||||
RETURNING VALUE(rv_base) TYPE ty_price.
|
||||
METHODS garment_factor
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
RETURNING VALUE(rv_factor) TYPE ty_price.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_quantity TYPE i
|
||||
RETURNING VALUE(rv_percent) TYPE ty_price.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS {{p}}tailor_pricer IMPLEMENTATION.
|
||||
|
||||
METHOD calculate_price.
|
||||
|
||||
DATA lv_base TYPE ty_price.
|
||||
DATA lv_factor TYPE ty_price.
|
||||
DATA lv_unit TYPE ty_price.
|
||||
DATA lv_total TYPE ty_price.
|
||||
DATA lv_discount TYPE ty_price.
|
||||
|
||||
IF iv_quantity <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_base = service_base( iv_service ).
|
||||
lv_factor = garment_factor( iv_garment ).
|
||||
IF lv_base <= 0 OR lv_factor <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_unit = lv_base * lv_factor.
|
||||
IF iv_express = abap_true.
|
||||
lv_unit = lv_unit - c_express_fee.
|
||||
ENDIF.
|
||||
|
||||
lv_total = lv_unit * iv_quantity.
|
||||
lv_discount = discount_percent( iv_quantity ).
|
||||
lv_total = lv_total - lv_total * lv_discount / c_percent_base.
|
||||
|
||||
IF lv_total < c_minimum_price.
|
||||
rv_price = c_minimum_price.
|
||||
ELSE.
|
||||
rv_price = lv_total.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD service_base.
|
||||
CASE iv_service.
|
||||
WHEN 'HEM'.
|
||||
rv_base = '8.00'.
|
||||
WHEN 'TAKE_IN'.
|
||||
rv_base = '15.00'.
|
||||
WHEN 'ZIP'.
|
||||
rv_base = '12.00'.
|
||||
WHEN 'SLEEVE'.
|
||||
rv_base = '10.00'.
|
||||
WHEN 'LINING'.
|
||||
rv_base = '25.00'.
|
||||
WHEN OTHERS.
|
||||
rv_base = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD garment_factor.
|
||||
CASE iv_garment.
|
||||
WHEN 'TROUSERS'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'SKIRT'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'JACKET'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'DRESS'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'COAT'.
|
||||
rv_factor = '2.00'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD discount_percent.
|
||||
IF iv_quantity >= c_qty_high.
|
||||
rv_percent = c_discount_high.
|
||||
ELSEIF iv_quantity >= c_qty_low.
|
||||
rv_percent = c_discount_low.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
126
tasks_gen/train/G1050/faulty/m3_tailor_pricer.clas.abap
Normal file
126
tasks_gen/train/G1050/faulty/m3_tailor_pricer.clas.abap
Normal file
@@ -0,0 +1,126 @@
|
||||
CLASS {{p}}tailor_pricer DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
||||
TYPES ty_garment TYPE c LENGTH 10.
|
||||
TYPES ty_service TYPE c LENGTH 10.
|
||||
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
METHODS calculate_price
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
iv_service TYPE ty_service
|
||||
iv_quantity TYPE i
|
||||
iv_express TYPE abap_bool
|
||||
RETURNING VALUE(rv_price) TYPE ty_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
|
||||
CONSTANTS:
|
||||
c_express_fee TYPE ty_price VALUE '6.00',
|
||||
c_minimum_price TYPE ty_price VALUE '15.00',
|
||||
c_discount_low TYPE ty_price VALUE '10.00',
|
||||
c_discount_high TYPE ty_price VALUE '20.00',
|
||||
c_qty_low TYPE i VALUE 3,
|
||||
c_qty_high TYPE i VALUE 5,
|
||||
c_percent_base TYPE i VALUE 100.
|
||||
|
||||
METHODS service_base
|
||||
IMPORTING iv_service TYPE ty_service
|
||||
RETURNING VALUE(rv_base) TYPE ty_price.
|
||||
METHODS garment_factor
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
RETURNING VALUE(rv_factor) TYPE ty_price.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_quantity TYPE i
|
||||
RETURNING VALUE(rv_percent) TYPE ty_price.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS {{p}}tailor_pricer IMPLEMENTATION.
|
||||
|
||||
METHOD calculate_price.
|
||||
|
||||
DATA lv_base TYPE ty_price.
|
||||
DATA lv_factor TYPE ty_price.
|
||||
DATA lv_unit TYPE ty_price.
|
||||
DATA lv_total TYPE ty_price.
|
||||
DATA lv_discount TYPE ty_price.
|
||||
|
||||
IF iv_quantity <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_base = service_base( iv_service ).
|
||||
lv_factor = garment_factor( iv_garment ).
|
||||
IF lv_base <= 0 OR lv_factor <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_unit = lv_base * lv_factor.
|
||||
IF iv_express = abap_true.
|
||||
lv_unit = lv_unit + c_express_fee.
|
||||
ENDIF.
|
||||
|
||||
lv_total = lv_unit * iv_quantity.
|
||||
lv_discount = discount_percent( iv_quantity ).
|
||||
lv_total = lv_total - lv_total * lv_discount / c_percent_base.
|
||||
|
||||
IF lv_total >= c_minimum_price.
|
||||
rv_price = c_minimum_price.
|
||||
ELSE.
|
||||
rv_price = lv_total.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD service_base.
|
||||
CASE iv_service.
|
||||
WHEN 'HEM'.
|
||||
rv_base = '8.00'.
|
||||
WHEN 'TAKE_IN'.
|
||||
rv_base = '15.00'.
|
||||
WHEN 'ZIP'.
|
||||
rv_base = '12.00'.
|
||||
WHEN 'SLEEVE'.
|
||||
rv_base = '10.00'.
|
||||
WHEN 'LINING'.
|
||||
rv_base = '25.00'.
|
||||
WHEN OTHERS.
|
||||
rv_base = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD garment_factor.
|
||||
CASE iv_garment.
|
||||
WHEN 'TROUSERS'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'SKIRT'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'JACKET'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'DRESS'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'COAT'.
|
||||
rv_factor = '2.00'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD discount_percent.
|
||||
IF iv_quantity >= c_qty_high.
|
||||
rv_percent = c_discount_high.
|
||||
ELSEIF iv_quantity >= c_qty_low.
|
||||
rv_percent = c_discount_low.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
126
tasks_gen/train/G1050/faulty/m4_tailor_pricer.clas.abap
Normal file
126
tasks_gen/train/G1050/faulty/m4_tailor_pricer.clas.abap
Normal file
@@ -0,0 +1,126 @@
|
||||
CLASS {{p}}tailor_pricer DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
||||
TYPES ty_garment TYPE c LENGTH 10.
|
||||
TYPES ty_service TYPE c LENGTH 10.
|
||||
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
METHODS calculate_price
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
iv_service TYPE ty_service
|
||||
iv_quantity TYPE i
|
||||
iv_express TYPE abap_bool
|
||||
RETURNING VALUE(rv_price) TYPE ty_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
|
||||
CONSTANTS:
|
||||
c_express_fee TYPE ty_price VALUE '6.00',
|
||||
c_minimum_price TYPE ty_price VALUE '15.00',
|
||||
c_discount_low TYPE ty_price VALUE '10.00',
|
||||
c_discount_high TYPE ty_price VALUE '20.00',
|
||||
c_qty_low TYPE i VALUE 3,
|
||||
c_qty_high TYPE i VALUE 5,
|
||||
c_percent_base TYPE i VALUE 100.
|
||||
|
||||
METHODS service_base
|
||||
IMPORTING iv_service TYPE ty_service
|
||||
RETURNING VALUE(rv_base) TYPE ty_price.
|
||||
METHODS garment_factor
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
RETURNING VALUE(rv_factor) TYPE ty_price.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_quantity TYPE i
|
||||
RETURNING VALUE(rv_percent) TYPE ty_price.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS {{p}}tailor_pricer IMPLEMENTATION.
|
||||
|
||||
METHOD calculate_price.
|
||||
|
||||
DATA lv_base TYPE ty_price.
|
||||
DATA lv_factor TYPE ty_price.
|
||||
DATA lv_unit TYPE ty_price.
|
||||
DATA lv_total TYPE ty_price.
|
||||
DATA lv_discount TYPE ty_price.
|
||||
|
||||
IF iv_quantity <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_base = service_base( iv_service ).
|
||||
lv_factor = garment_factor( iv_garment ).
|
||||
IF lv_base <= 0 OR lv_factor <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_unit = lv_base * lv_factor.
|
||||
IF iv_express = abap_true.
|
||||
lv_unit = lv_unit + c_express_fee.
|
||||
ENDIF.
|
||||
|
||||
lv_total = lv_unit * iv_quantity.
|
||||
lv_discount = discount_percent( iv_quantity ).
|
||||
lv_total = lv_total - lv_total * lv_discount / c_percent_base.
|
||||
|
||||
IF lv_total < c_minimum_price.
|
||||
rv_price = c_minimum_price.
|
||||
ELSE.
|
||||
rv_price = lv_total.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD service_base.
|
||||
CASE iv_service.
|
||||
WHEN 'HEM'.
|
||||
rv_base = '8.00'.
|
||||
WHEN 'TAKE_IN'.
|
||||
rv_base = '15.00'.
|
||||
WHEN 'ZIP'.
|
||||
rv_base = '12.00'.
|
||||
WHEN 'SLEEVE'.
|
||||
rv_base = '10.00'.
|
||||
WHEN 'LINING'.
|
||||
rv_base = '25.00'.
|
||||
WHEN OTHERS.
|
||||
rv_base = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD garment_factor.
|
||||
CASE iv_garment.
|
||||
WHEN 'TROUSERS'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'SKIRT'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'JACKET'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'DRESS'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'COAT'.
|
||||
rv_factor = '2.00'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD discount_percent.
|
||||
IF iv_quantity < c_qty_high.
|
||||
rv_percent = c_discount_high.
|
||||
ELSEIF iv_quantity >= c_qty_low.
|
||||
rv_percent = c_discount_low.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
44
tasks_gen/train/G1050/generation.json
Normal file
44
tasks_gen/train/G1050/generation.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"id": "G1050",
|
||||
"pool": "train",
|
||||
"object_type": "CLAS",
|
||||
"category": "E",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"reference/tailor_pricer.clas.abap line 100: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"rt_factor\"",
|
||||
"reference/tailor_pricer.clas.abap line 102: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"5\"",
|
||||
"reference/tailor_pricer.clas.abap line 103: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"5\""
|
||||
],
|
||||
"by_check": {
|
||||
"abaplint": 3
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 88.9,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"invalid JSON: Unterminated string starting at: line 1 column 5615 (char 5614)"
|
||||
],
|
||||
"by_check": {
|
||||
"json": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
131
tasks_gen/train/G1050/hidden/tailor_pricer_hidden.clas.abap
Normal file
131
tasks_gen/train/G1050/hidden/tailor_pricer_hidden.clas.abap
Normal file
@@ -0,0 +1,131 @@
|
||||
CLASS {{p}}tailor_hidden DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC
|
||||
FOR TESTING
|
||||
DURATION SHORT
|
||||
RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}tailor_pricer.
|
||||
METHODS setup.
|
||||
METHODS minimum_price FOR TESTING.
|
||||
METHODS ten_percent_discount FOR TESTING.
|
||||
METHODS twenty_percent_discount FOR TESTING.
|
||||
METHODS express_fee FOR TESTING.
|
||||
METHODS express_hits_minimum FOR TESTING.
|
||||
METHODS coat_lining FOR TESTING.
|
||||
METHODS unknown_service FOR TESTING.
|
||||
METHODS unknown_garment FOR TESTING.
|
||||
METHODS zero_quantity FOR TESTING.
|
||||
METHODS negative_quantity FOR TESTING.
|
||||
METHODS plain_price FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}tailor_hidden IMPLEMENTATION.
|
||||
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}tailor_pricer( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD minimum_price.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '15.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'TROUSERS'
|
||||
iv_service = 'HEM'
|
||||
iv_quantity = 1
|
||||
iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ten_percent_discount.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '32.40' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'SKIRT'
|
||||
iv_service = 'ZIP'
|
||||
iv_quantity = 3
|
||||
iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD twenty_percent_discount.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '32.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'TROUSERS'
|
||||
iv_service = 'HEM'
|
||||
iv_quantity = 5
|
||||
iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD express_fee.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '57.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'JACKET'
|
||||
iv_service = 'TAKE_IN'
|
||||
iv_quantity = 2
|
||||
iv_express = abap_true ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD express_hits_minimum.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '15.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'TROUSERS'
|
||||
iv_service = 'HEM'
|
||||
iv_quantity = 1
|
||||
iv_express = abap_true ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD coat_lining.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '135.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'COAT'
|
||||
iv_service = 'LINING'
|
||||
iv_quantity = 3
|
||||
iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_service.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '0.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'TROUSERS'
|
||||
iv_service = 'PATCH'
|
||||
iv_quantity = 2
|
||||
iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_garment.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '0.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'SHIRT'
|
||||
iv_service = 'HEM'
|
||||
iv_quantity = 2
|
||||
iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_quantity.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '0.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'TROUSERS'
|
||||
iv_service = 'HEM'
|
||||
iv_quantity = 0
|
||||
iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD negative_quantity.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '0.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'TROUSERS'
|
||||
iv_service = 'HEM'
|
||||
iv_quantity = -2
|
||||
iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD plain_price.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '18.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'JACKET'
|
||||
iv_service = 'ZIP'
|
||||
iv_quantity = 1
|
||||
iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
69
tasks_gen/train/G1050/mutation.json
Normal file
69
tasks_gen/train/G1050/mutation.json
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"task": "G1050",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}TAILOR_PRICER",
|
||||
"mutant": "line 60: OR -> AND (logic)",
|
||||
"status": "killed",
|
||||
"hidden": "9/11",
|
||||
"failed_tests": [
|
||||
"UNKNOWN_GARMENT",
|
||||
"UNKNOWN_SERVICE"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}TAILOR_PRICER",
|
||||
"mutant": "line 65: = -> <> (eq)",
|
||||
"status": "killed",
|
||||
"hidden": "6/11",
|
||||
"failed_tests": [
|
||||
"COAT_LINING",
|
||||
"EXPRESS_FEE",
|
||||
"PLAIN_PRICE",
|
||||
"TEN_PERCENT_DISCOUNT",
|
||||
"TWENTY_PERCENT_DISCOUNT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}TAILOR_PRICER",
|
||||
"mutant": "line 66: + -> - (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "10/11",
|
||||
"failed_tests": [
|
||||
"EXPRESS_FEE"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}TAILOR_PRICER",
|
||||
"mutant": "line 73: < -> >= (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "4/11",
|
||||
"failed_tests": [
|
||||
"COAT_LINING",
|
||||
"EXPRESS_FEE",
|
||||
"EXPRESS_HITS_MINIMUM",
|
||||
"MINIMUM_PRICE",
|
||||
"PLAIN_PRICE",
|
||||
"TEN_PERCENT_DISCOUNT",
|
||||
"TWENTY_PERCENT_DISCOUNT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}TAILOR_PRICER",
|
||||
"mutant": "line 119: >= -> < (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "6/11",
|
||||
"failed_tests": [
|
||||
"COAT_LINING",
|
||||
"EXPRESS_FEE",
|
||||
"PLAIN_PRICE",
|
||||
"TEN_PERCENT_DISCOUNT",
|
||||
"TWENTY_PERCENT_DISCOUNT"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
126
tasks_gen/train/G1050/reference/tailor_pricer.clas.abap
Normal file
126
tasks_gen/train/G1050/reference/tailor_pricer.clas.abap
Normal file
@@ -0,0 +1,126 @@
|
||||
CLASS {{p}}tailor_pricer DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
||||
TYPES ty_garment TYPE c LENGTH 10.
|
||||
TYPES ty_service TYPE c LENGTH 10.
|
||||
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
METHODS calculate_price
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
iv_service TYPE ty_service
|
||||
iv_quantity TYPE i
|
||||
iv_express TYPE abap_bool
|
||||
RETURNING VALUE(rv_price) TYPE ty_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
|
||||
CONSTANTS:
|
||||
c_express_fee TYPE ty_price VALUE '6.00',
|
||||
c_minimum_price TYPE ty_price VALUE '15.00',
|
||||
c_discount_low TYPE ty_price VALUE '10.00',
|
||||
c_discount_high TYPE ty_price VALUE '20.00',
|
||||
c_qty_low TYPE i VALUE 3,
|
||||
c_qty_high TYPE i VALUE 5,
|
||||
c_percent_base TYPE i VALUE 100.
|
||||
|
||||
METHODS service_base
|
||||
IMPORTING iv_service TYPE ty_service
|
||||
RETURNING VALUE(rv_base) TYPE ty_price.
|
||||
METHODS garment_factor
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
RETURNING VALUE(rv_factor) TYPE ty_price.
|
||||
METHODS discount_percent
|
||||
IMPORTING iv_quantity TYPE i
|
||||
RETURNING VALUE(rv_percent) TYPE ty_price.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS {{p}}tailor_pricer IMPLEMENTATION.
|
||||
|
||||
METHOD calculate_price.
|
||||
|
||||
DATA lv_base TYPE ty_price.
|
||||
DATA lv_factor TYPE ty_price.
|
||||
DATA lv_unit TYPE ty_price.
|
||||
DATA lv_total TYPE ty_price.
|
||||
DATA lv_discount TYPE ty_price.
|
||||
|
||||
IF iv_quantity <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_base = service_base( iv_service ).
|
||||
lv_factor = garment_factor( iv_garment ).
|
||||
IF lv_base <= 0 OR lv_factor <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lv_unit = lv_base * lv_factor.
|
||||
IF iv_express = abap_true.
|
||||
lv_unit = lv_unit + c_express_fee.
|
||||
ENDIF.
|
||||
|
||||
lv_total = lv_unit * iv_quantity.
|
||||
lv_discount = discount_percent( iv_quantity ).
|
||||
lv_total = lv_total - lv_total * lv_discount / c_percent_base.
|
||||
|
||||
IF lv_total < c_minimum_price.
|
||||
rv_price = c_minimum_price.
|
||||
ELSE.
|
||||
rv_price = lv_total.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD service_base.
|
||||
CASE iv_service.
|
||||
WHEN 'HEM'.
|
||||
rv_base = '8.00'.
|
||||
WHEN 'TAKE_IN'.
|
||||
rv_base = '15.00'.
|
||||
WHEN 'ZIP'.
|
||||
rv_base = '12.00'.
|
||||
WHEN 'SLEEVE'.
|
||||
rv_base = '10.00'.
|
||||
WHEN 'LINING'.
|
||||
rv_base = '25.00'.
|
||||
WHEN OTHERS.
|
||||
rv_base = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD garment_factor.
|
||||
CASE iv_garment.
|
||||
WHEN 'TROUSERS'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'SKIRT'.
|
||||
rv_factor = '1.00'.
|
||||
WHEN 'JACKET'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'DRESS'.
|
||||
rv_factor = '1.50'.
|
||||
WHEN 'COAT'.
|
||||
rv_factor = '2.00'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD discount_percent.
|
||||
IF iv_quantity >= c_qty_high.
|
||||
rv_percent = c_discount_high.
|
||||
ELSEIF iv_quantity >= c_qty_low.
|
||||
rv_percent = c_discount_low.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,70 @@
|
||||
CLASS ltc_tailor_pricer DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}tailor_pricer.
|
||||
METHODS setup.
|
||||
METHODS minimum_price FOR TESTING.
|
||||
METHODS ten_percent_discount FOR TESTING.
|
||||
METHODS twenty_percent_discount FOR TESTING.
|
||||
METHODS express_fee FOR TESTING.
|
||||
METHODS unknown_service FOR TESTING.
|
||||
METHODS unknown_garment FOR TESTING.
|
||||
METHODS no_quantity FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_tailor_pricer IMPLEMENTATION.
|
||||
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}tailor_pricer( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD minimum_price.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '15.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'TROUSERS' iv_service = 'HEM'
|
||||
iv_quantity = 1 iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ten_percent_discount.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '32.40' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'SKIRT' iv_service = 'ZIP'
|
||||
iv_quantity = 3 iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD twenty_percent_discount.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '32.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'TROUSERS' iv_service = 'HEM'
|
||||
iv_quantity = 5 iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD express_fee.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '57.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'JACKET' iv_service = 'TAKE_IN'
|
||||
iv_quantity = 2 iv_express = abap_true ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_service.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '0.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'TROUSERS' iv_service = 'PATCH'
|
||||
iv_quantity = 2 iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_garment.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '0.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'SHIRT' iv_service = 'HEM'
|
||||
iv_quantity = 2 iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD no_quantity.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}tailor_pricer=>ty_price( '0.00' )
|
||||
act = mo_cut->calculate_price( iv_garment = 'TROUSERS' iv_service = 'HEM'
|
||||
iv_quantity = 0 iv_express = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
104
tasks_gen/train/G1050/seed/tailor_pricer.clas.abap
Normal file
104
tasks_gen/train/G1050/seed/tailor_pricer.clas.abap
Normal file
@@ -0,0 +1,104 @@
|
||||
CLASS {{p}}tailor_pricer DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
||||
TYPES ty_garment TYPE c LENGTH 10.
|
||||
TYPES ty_service TYPE c LENGTH 10.
|
||||
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
METHODS calculate_price
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
iv_service TYPE ty_service
|
||||
iv_quantity TYPE i
|
||||
iv_express TYPE abap_bool
|
||||
RETURNING VALUE(rv_price) TYPE ty_price.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS {{p}}tailor_pricer IMPLEMENTATION.
|
||||
|
||||
METHOD calculate_price.
|
||||
|
||||
DATA lv_base TYPE ty_price.
|
||||
DATA lv_factor TYPE ty_price.
|
||||
DATA lv_total TYPE ty_price.
|
||||
DATA lv_disc TYPE ty_price.
|
||||
|
||||
rv_price = 0.
|
||||
|
||||
" a job needs at least one garment
|
||||
IF iv_quantity > 0.
|
||||
|
||||
" base price of the service
|
||||
IF iv_service = 'HEM'.
|
||||
lv_base = '8.00'.
|
||||
ELSEIF iv_service = 'TAKE_IN'.
|
||||
lv_base = '15.00'.
|
||||
ELSEIF iv_service = 'ZIP'.
|
||||
lv_base = '12.00'.
|
||||
ELSEIF iv_service = 'SLEEVE'.
|
||||
lv_base = '10.00'.
|
||||
ELSEIF iv_service = 'LINING'.
|
||||
lv_base = '25.00'.
|
||||
ELSE.
|
||||
lv_base = '0.00'.
|
||||
ENDIF.
|
||||
|
||||
" factor of the garment
|
||||
IF iv_garment = 'TROUSERS'.
|
||||
lv_factor = '1.00'.
|
||||
ELSEIF iv_garment = 'SKIRT'.
|
||||
lv_factor = '1.00'.
|
||||
ELSEIF iv_garment = 'JACKET'.
|
||||
lv_factor = '1.50'.
|
||||
ELSEIF iv_garment = 'DRESS'.
|
||||
lv_factor = '1.50'.
|
||||
ELSEIF iv_garment = 'COAT'.
|
||||
lv_factor = '2.00'.
|
||||
ELSE.
|
||||
lv_factor = '0.00'.
|
||||
ENDIF.
|
||||
|
||||
IF lv_base > '0.00' AND lv_factor > '0.00'.
|
||||
|
||||
" price of one garment
|
||||
lv_total = lv_base * lv_factor.
|
||||
|
||||
" express service costs more
|
||||
IF iv_express = 'X'.
|
||||
lv_total = lv_total + '6.00'.
|
||||
ENDIF.
|
||||
|
||||
" price of all garments
|
||||
lv_total = lv_total * iv_quantity.
|
||||
|
||||
" discount for many garments
|
||||
IF iv_quantity >= 5.
|
||||
lv_disc = '20.00'.
|
||||
ELSEIF iv_quantity >= 3.
|
||||
lv_disc = '10.00'.
|
||||
ELSE.
|
||||
lv_disc = '0.00'.
|
||||
ENDIF.
|
||||
|
||||
lv_total = lv_total - lv_total * lv_disc / 100.
|
||||
|
||||
" the shop has a minimum order value
|
||||
IF lv_total < '15.00'.
|
||||
lv_total = '15.00'.
|
||||
ENDIF.
|
||||
|
||||
rv_price = lv_total.
|
||||
|
||||
ENDIF.
|
||||
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
47
tasks_gen/train/G1050/spec.md
Normal file
47
tasks_gen/train/G1050/spec.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# 1. Goal
|
||||
Refactor the legacy class {{P}}TAILOR_PRICER in package $TMP. The class calculates
|
||||
the price of an alteration job in a tailor shop. The shop terminal calls the class
|
||||
for each job. The behavior of the class must stay the same.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The class {{P}}TAILOR_PRICER exists in package $TMP. It is active.
|
||||
- The class is public and final. The public constructor has no parameters.
|
||||
- The shop terminal calls the public method CALCULATE_PRICE for each job.
|
||||
- The legacy implementation is correct. It is also long, deeply nested, and full of
|
||||
magic numbers. It is hard to read and hard to change.
|
||||
- The customers do not accept different prices. The same input must give the same
|
||||
result as before.
|
||||
|
||||
# 4. Contract
|
||||
- The class {{P}}TAILOR_PRICER stays in package $TMP. Do not rename it.
|
||||
- The class stays public and final. The public constructor stays without parameters.
|
||||
- The public types ty_garment, ty_service, and ty_price stay unchanged.
|
||||
- The public method stays unchanged:
|
||||
calculate_price
|
||||
IMPORTING iv_garment TYPE ty_garment
|
||||
iv_service TYPE ty_service
|
||||
iv_quantity TYPE i
|
||||
iv_express TYPE abap_bool
|
||||
RETURNING VALUE(rv_price) TYPE ty_price.
|
||||
- Do not add other public methods, public attributes, or public types.
|
||||
|
||||
# 5. Business rules
|
||||
The legacy implementation of {{P}}TAILOR_PRICER defines the price rules. Read the
|
||||
legacy code in the seed object. Keep every rule, the sequence of the rules, and all
|
||||
special cases. The behavior stays the same for every input combination.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816.
|
||||
- Coding standards: Clean ABAP. Methods below 40 statements. Maximum nesting depth
|
||||
of 3. No magic numbers, use constants. No global variables. No comment that
|
||||
restates the code.
|
||||
- Out of scope: do not change the public interface. Do not change the class name.
|
||||
Do not add public members. Do not change the price rules.
|
||||
|
||||
# 7. Acceptance
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests as local test classes in the class.
|
||||
48
tasks_gen/train/G1050/task.json
Normal file
48
tasks_gen/train/G1050/task.json
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"id": "G1050",
|
||||
"category": "E",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}TAILOR_PRICER",
|
||||
"file": "seed/tailor_pricer.clas.abap",
|
||||
"description": "Legacy tailor alteration price calculation"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}TAILOR_PRICER"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}TAILOR_HIDDEN",
|
||||
"file": "hidden/tailor_pricer_hidden.clas.abap",
|
||||
"description": "Hidden tests for the refactored tailor pricer"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}TAILOR_PRICER",
|
||||
"file": "reference/tailor_pricer.clas.abap",
|
||||
"description": "Refactored tailor pricer",
|
||||
"testclasses_file": "reference/tailor_pricer.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"cyclomatic_complexity"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user