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,14 @@
{
"id": "G1087",
"pool": "train",
"object_type": "CLAS",
"category": "H",
"attempts": [
{
"stage": "validate",
"oracle": 100,
"null": 30
}
],
"accepted": true
}

View 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.

View 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.

View File

@@ -0,0 +1,21 @@
INTERFACE {{p}}if_tool_hire PUBLIC.
TYPES ty_tool TYPE c LENGTH 1.
TYPES ty_days TYPE i.
TYPES ty_amount TYPE p LENGTH 13 DECIMALS 2.
TYPES ty_reason TYPE c LENGTH 12.
TYPES:
BEGIN OF ty_result,
fee TYPE ty_amount,
reason TYPE ty_reason,
END OF ty_result.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
unknown_tool TYPE ty_reason VALUE 'UNKNOWN_TOOL',
too_short TYPE ty_reason VALUE 'TOO_SHORT',
END OF c_reason.
METHODS calculate
IMPORTING iv_tool TYPE ty_tool
iv_days TYPE ty_days
RETURNING VALUE(rs_result) TYPE ty_result.
ENDINTERFACE.

View File

@@ -0,0 +1,52 @@
# 1. Goal
A tool hire shop rents power tools to its customers. The checkout program calls
the class {{P}}TOOL_HIRE for each hire request before it prints the hire
contract. The program needs the fee of the hire and one reason code.
# 2. Open questions
None.
# 3. Context
- Interface {{P}}IF_TOOL_HIRE exists in package $TMP. It is active.
- The interface has these types: TY_TOOL (CHAR 1), TY_DAYS (integer),
TY_AMOUNT (packed, 13 digits, 2 decimals), TY_REASON (CHAR 12).
- The interface has the structure TY_RESULT with the components FEE and REASON.
- The interface has the constant structure C_REASON with the values OK,
UNKNOWN_TOOL and TOO_SHORT.
- The interface has one method:
CALCULATE IMPORTING iv_tool TYPE ty_tool
iv_days TYPE ty_days
RETURNING VALUE(rs_result) TYPE ty_result.
# 4. Contract
- Create the class {{P}}TOOL_HIRE in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class implements {{P}}IF_TOOL_HIRE.
- Do not add other public methods.
# 5. Business rules
1. The tool category is one character. These categories exist: 'D' is a drill,
'S' is a sander, 'C' is a tile cutter. Every other category is unknown. For
an unknown category return the reason UNKNOWN_TOOL and the fee 0.00.
2. A hire of less than 1 day is not possible. Return the reason TOO_SHORT and
the fee 0.00.
3. The daily rate is 12.00 for 'D', 9.00 for 'S' and 15.00 for 'C'. A hire of
1 to 6 days costs the daily rate multiplied by the number of days.
4. A hire of 7 days or more costs the weekly rate instead of the daily rate.
The weekly rate is 60.00 for 'D', 45.00 for 'S' and 75.00 for 'C'.
5. A hire of 28 days or more costs the monthly rate instead of the weekly rate.
The monthly rate is 180.00 for 'D', 135.00 for 'S' and 225.00 for 'C'.
6. The shop accepts hires of at most 90 days.
7. For every accepted hire return the reason OK and the fee of the hire.
8. The checkout program calls the class for every hire request, also for
requests that the shop cannot accept.
# 6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- 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_TOOL_HIRE.
# 7. Acceptance
- The class is active and has no syntax error.
- Write your own ABAP Unit tests for the class.

View File

@@ -0,0 +1,61 @@
{
"id": "G1087",
"category": "H",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "stop",
"expected_gap": {
"description": "The spec states that the shop accepts hires of at most 90 days but does not say which fee and which reason code the class returns for a hire that is longer than 90 days.",
"keywords": [
[
"90",
"days"
],
[
"reason",
"fee"
],
[
"return",
"90"
]
]
},
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "INTF",
"name": "{{P}}IF_TOOL_HIRE",
"file": "seed/if_tool_hire.intf.abap",
"description": "Tool hire contract with types, reason codes and the calculate method"
}
],
"contract": [
{
"type": "CLAS",
"name": "{{P}}TOOL_HIRE",
"implements": "{{P}}IF_TOOL_HIRE"
}
],
"out_of_scope": [
"{{P}}IF_TOOL_HIRE"
],
"hidden_tests": [],
"reference": [
{
"type": "CLAS",
"name": "{{P}}TOOL_HIRE",
"file": "reference/tool_hire.clas.abap",
"description": "Tool hire fee calculator",
"testclasses_file": "reference/tool_hire.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"nesting_depth"
]
}