Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
62
tasks_gen/train/G1087/reference/tool_hire.clas.abap
Normal file
62
tasks_gen/train/G1087/reference/tool_hire.clas.abap
Normal file
@@ -0,0 +1,62 @@
|
||||
CLASS {{p}}tool_hire DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_tool_hire.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_rate,
|
||||
tool TYPE {{p}}if_tool_hire=>ty_tool,
|
||||
daily TYPE {{p}}if_tool_hire=>ty_amount,
|
||||
weekly TYPE {{p}}if_tool_hire=>ty_amount,
|
||||
monthly TYPE {{p}}if_tool_hire=>ty_amount,
|
||||
END OF ty_rate,
|
||||
tt_rate TYPE HASHED TABLE OF ty_rate WITH UNIQUE KEY tool.
|
||||
|
||||
CONSTANTS:
|
||||
c_week_days TYPE i VALUE 7,
|
||||
c_month_days TYPE i VALUE 28,
|
||||
c_max_days TYPE i VALUE 90.
|
||||
|
||||
METHODS rates
|
||||
RETURNING VALUE(rt_rate) TYPE tt_rate.
|
||||
METHODS fee_for
|
||||
IMPORTING is_rate TYPE ty_rate
|
||||
iv_days TYPE {{p}}if_tool_hire=>ty_days
|
||||
RETURNING VALUE(rv_fee) TYPE {{p}}if_tool_hire=>ty_amount.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}tool_hire IMPLEMENTATION.
|
||||
METHOD {{p}}if_tool_hire~calculate.
|
||||
DATA(lt_rate) = rates( ).
|
||||
ASSIGN lt_rate[ tool = iv_tool ] TO FIELD-SYMBOL(<ls_rate>).
|
||||
IF sy-subrc <> 0.
|
||||
rs_result = VALUE #( fee = 0
|
||||
reason = {{p}}if_tool_hire=>c_reason-unknown_tool ).
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_days < 1 OR iv_days > c_max_days.
|
||||
rs_result = VALUE #( fee = 0
|
||||
reason = {{p}}if_tool_hire=>c_reason-too_short ).
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rs_result = VALUE #( fee = fee_for( is_rate = <ls_rate> iv_days = iv_days )
|
||||
reason = {{p}}if_tool_hire=>c_reason-ok ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rates.
|
||||
rt_rate = VALUE #( ( tool = 'D' daily = 12 weekly = 60 monthly = 180 )
|
||||
( tool = 'S' daily = 9 weekly = 45 monthly = 135 )
|
||||
( tool = 'C' daily = 15 weekly = 75 monthly = 225 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD fee_for.
|
||||
IF iv_days >= c_month_days.
|
||||
rv_fee = is_rate-monthly.
|
||||
ELSEIF iv_days >= c_week_days.
|
||||
rv_fee = is_rate-weekly.
|
||||
ELSE.
|
||||
rv_fee = is_rate-daily * iv_days.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
67
tasks_gen/train/G1087/reference/tool_hire.testclasses.abap
Normal file
67
tasks_gen/train/G1087/reference/tool_hire.testclasses.abap
Normal file
@@ -0,0 +1,67 @@
|
||||
CLASS ltc_tool_hire DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_amount TYPE {{p}}if_tool_hire=>ty_amount.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_tool_hire.
|
||||
METHODS setup.
|
||||
METHODS daily_rate FOR TESTING.
|
||||
METHODS weekly_rate FOR TESTING.
|
||||
METHODS monthly_rate FOR TESTING.
|
||||
METHODS unknown_tool FOR TESTING.
|
||||
METHODS zero_days FOR TESTING.
|
||||
METHODS over_maximum FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_tool_hire IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}tool_hire( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD daily_rate.
|
||||
DATA(ls_result) = mo_cut->calculate( iv_tool = 'D' iv_days = 3 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '36.00' )
|
||||
act = ls_result-fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weekly_rate.
|
||||
DATA(ls_result) = mo_cut->calculate( iv_tool = 'S' iv_days = 10 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '45.00' )
|
||||
act = ls_result-fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD monthly_rate.
|
||||
DATA(ls_result) = mo_cut->calculate( iv_tool = 'C' iv_days = 30 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '225.00' )
|
||||
act = ls_result-fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_tool.
|
||||
DATA(ls_result) = mo_cut->calculate( iv_tool = 'X' iv_days = 5 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '0.00' )
|
||||
act = ls_result-fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-unknown_tool
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_days.
|
||||
DATA(ls_result) = mo_cut->calculate( iv_tool = 'D' iv_days = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '0.00' )
|
||||
act = ls_result-fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-too_short
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD over_maximum.
|
||||
DATA(ls_result) = mo_cut->calculate( iv_tool = 'D' iv_days = 100 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '0.00' )
|
||||
act = ls_result-fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-too_short
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user