Stage 2 summary at 50 accepted trajectories

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 18:02:52 +02:00
parent 332fb4601d
commit 5bcd1bf9cd
1230 changed files with 77563 additions and 33 deletions

View File

@@ -0,0 +1,34 @@
FUNCTION {{p}}key_price
IMPORTING
iv_key_type TYPE string
iv_quantity TYPE i
EXPORTING
ev_price TYPE decfloat34
ev_valid TYPE abap_bool
EXCEPTIONS
invalid_quantity.
DATA lv_unit_price TYPE decfloat34.
ev_price = 0.
ev_valid = abap_false.
IF iv_quantity < 1.
RAISE invalid_quantity.
ENDIF.
CASE iv_key_type.
WHEN 'ST'.
lv_unit_price = '3.50'.
WHEN 'SE'.
lv_unit_price = '12.00'.
WHEN 'TR'.
lv_unit_price = '45.00'.
WHEN OTHERS.
RETURN.
ENDCASE.
ev_price = lv_unit_price * iv_quantity.
IF iv_quantity >= 10.
ev_price = ev_price * '0.9'.
ENDIF.
ev_price = round( val = ev_price dec = 2 mode = cl_abap_math=>round_half_up ).
ev_valid = abap_true.
ENDFUNCTION.

View File

@@ -0,0 +1,49 @@
CLASS {{p}}key_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS price_for IMPORTING iv_key_type TYPE string iv_quantity TYPE i
RETURNING VALUE(rv_price) TYPE decfloat34.
METHODS standard_price FOR TESTING.
METHODS security_price FOR TESTING.
METHODS transponder_price FOR TESTING.
METHODS discount FOR TESTING.
METHODS invalid_quantity FOR TESTING.
ENDCLASS.
CLASS {{p}}key_test IMPLEMENTATION.
METHOD price_for.
DATA lv_valid TYPE abap_bool.
CALL FUNCTION '{{P}}KEY_PRICE'
EXPORTING iv_key_type = iv_key_type iv_quantity = iv_quantity
IMPORTING ev_price = rv_price ev_valid = lv_valid
EXCEPTIONS invalid_quantity = 1 OTHERS = 2.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
ENDMETHOD.
METHOD standard_price.
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '10.50' ) act = price_for( iv_key_type = 'ST' iv_quantity = 3 ) ).
ENDMETHOD.
METHOD security_price.
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '24.00' ) act = price_for( iv_key_type = 'SE' iv_quantity = 2 ) ).
ENDMETHOD.
METHOD transponder_price.
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '45.00' ) act = price_for( iv_key_type = 'TR' iv_quantity = 1 ) ).
ENDMETHOD.
METHOD discount.
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '31.50' ) act = price_for( iv_key_type = 'ST' iv_quantity = 10 ) ).
ENDMETHOD.
METHOD invalid_quantity.
DATA lv_price TYPE decfloat34.
DATA lv_valid TYPE abap_bool.
CALL FUNCTION '{{P}}KEY_PRICE'
EXPORTING iv_key_type = 'ST' iv_quantity = 0
IMPORTING ev_price = lv_price ev_valid = lv_valid
EXCEPTIONS invalid_quantity = 1 OTHERS = 2.
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
ENDMETHOD.
ENDCLASS.