Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
24
tasks_gen/train/G1104/reference/cx_golf.clas.abap
Normal file
24
tasks_gen/train/G1104/reference/cx_golf.clas.abap
Normal file
@@ -0,0 +1,24 @@
|
||||
CLASS {{p}}cx_golf DEFINITION
|
||||
PUBLIC
|
||||
INHERITING FROM cx_static_check
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS constructor
|
||||
IMPORTING
|
||||
iv_reason TYPE string
|
||||
iv_message TYPE string.
|
||||
|
||||
DATA mv_reason TYPE string READ-ONLY.
|
||||
DATA mv_message TYPE string READ-ONLY.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_golf IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
mv_reason = iv_reason.
|
||||
mv_message = iv_message.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
67
tasks_gen/train/G1104/reference/golf_fee.func.abap
Normal file
67
tasks_gen/train/G1104/reference/golf_fee.func.abap
Normal file
@@ -0,0 +1,67 @@
|
||||
FUNCTION {{p}}golf_fee
|
||||
IMPORTING
|
||||
iv_category TYPE string
|
||||
iv_holes TYPE i
|
||||
iv_players TYPE i
|
||||
iv_tee_hour TYPE i
|
||||
EXPORTING
|
||||
ev_fee TYPE decfloat34
|
||||
RAISING
|
||||
{{p}}cx_golf.
|
||||
|
||||
CONSTANTS: c_member TYPE decfloat34 VALUE '25.00',
|
||||
c_guest TYPE decfloat34 VALUE '62.50',
|
||||
c_junior TYPE decfloat34 VALUE '12.50'.
|
||||
|
||||
DATA lv_per_player TYPE decfloat34.
|
||||
|
||||
IF iv_players < 1 OR iv_players > 4.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_golf
|
||||
EXPORTING
|
||||
iv_reason = 'INVALID_PLAYERS'
|
||||
iv_message = 'Number of players must be between 1 and 4'.
|
||||
ENDIF.
|
||||
|
||||
IF iv_holes <> 9 AND iv_holes <> 18.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_golf
|
||||
EXPORTING
|
||||
iv_reason = 'INVALID_HOLES'
|
||||
iv_message = 'Number of holes must be 9 or 18'.
|
||||
ENDIF.
|
||||
|
||||
CASE iv_category.
|
||||
WHEN 'M'.
|
||||
lv_per_player = c_member.
|
||||
WHEN 'G'.
|
||||
lv_per_player = c_guest.
|
||||
WHEN 'J'.
|
||||
lv_per_player = c_junior.
|
||||
WHEN OTHERS.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_golf
|
||||
EXPORTING
|
||||
iv_reason = 'INVALID_CATEGORY'
|
||||
iv_message = 'Player category must be M, G or J'.
|
||||
ENDCASE.
|
||||
|
||||
IF iv_tee_hour < 6 OR iv_tee_hour > 20.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_golf
|
||||
EXPORTING
|
||||
iv_reason = 'INVALID_TEE_HOUR'
|
||||
iv_message = 'Tee hour must be between 6 and 20'.
|
||||
ENDIF.
|
||||
|
||||
IF iv_holes = 9.
|
||||
lv_per_player = lv_per_player / 2.
|
||||
ENDIF.
|
||||
|
||||
IF iv_tee_hour >= 18.
|
||||
lv_per_player = round( val = lv_per_player * 75 / 100 dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ENDIF.
|
||||
|
||||
ev_fee = lv_per_player * iv_players.
|
||||
|
||||
IF iv_players = 4.
|
||||
ev_fee = round( val = ev_fee * 90 / 100 dec = 2 mode = cl_abap_math=>round_half_up ).
|
||||
ENDIF.
|
||||
|
||||
ENDFUNCTION.
|
||||
78
tasks_gen/train/G1104/reference/t71_test.clas.abap
Normal file
78
tasks_gen/train/G1104/reference/t71_test.clas.abap
Normal file
@@ -0,0 +1,78 @@
|
||||
CLASS {{p}}t71_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS fee_for
|
||||
IMPORTING
|
||||
iv_category TYPE string
|
||||
iv_holes TYPE i
|
||||
iv_players TYPE i
|
||||
iv_tee_hour TYPE i
|
||||
RETURNING
|
||||
VALUE(rv_fee) TYPE decfloat34.
|
||||
|
||||
METHODS reason_for
|
||||
IMPORTING
|
||||
iv_category TYPE string
|
||||
iv_holes TYPE i
|
||||
iv_players TYPE i
|
||||
iv_tee_hour TYPE i
|
||||
RETURNING
|
||||
VALUE(rv_reason) TYPE string.
|
||||
|
||||
METHODS member_fee FOR TESTING.
|
||||
METHODS twilight_and_group FOR TESTING.
|
||||
METHODS invalid_holes FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t71_test IMPLEMENTATION.
|
||||
METHOD fee_for.
|
||||
TRY.
|
||||
CALL FUNCTION '{{P}}GOLF_FEE'
|
||||
EXPORTING
|
||||
iv_category = iv_category
|
||||
iv_holes = iv_holes
|
||||
iv_players = iv_players
|
||||
iv_tee_hour = iv_tee_hour
|
||||
IMPORTING
|
||||
ev_fee = rv_fee.
|
||||
CATCH {{p}}cx_golf.
|
||||
cl_abap_unit_assert=>fail( msg = 'no exception expected' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD reason_for.
|
||||
DATA lv_fee TYPE decfloat34.
|
||||
TRY.
|
||||
CALL FUNCTION '{{P}}GOLF_FEE'
|
||||
EXPORTING
|
||||
iv_category = iv_category
|
||||
iv_holes = iv_holes
|
||||
iv_players = iv_players
|
||||
iv_tee_hour = iv_tee_hour
|
||||
IMPORTING
|
||||
ev_fee = lv_fee.
|
||||
CATCH {{p}}cx_golf INTO DATA(lo_exc).
|
||||
rv_reason = lo_exc->mv_reason.
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD member_fee.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV decfloat34( 25 )
|
||||
act = fee_for( iv_category = 'M' iv_holes = 18 iv_players = 1 iv_tee_hour = 6 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD twilight_and_group.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV decfloat34( '168.77' )
|
||||
act = fee_for( iv_category = 'G' iv_holes = 18 iv_players = 4 iv_tee_hour = 19 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_holes.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = `INVALID_HOLES`
|
||||
act = reason_for( iv_category = 'M' iv_holes = 12 iv_players = 1 iv_tee_hour = 10 ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user