Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
14
tasks_gen/train/G1059/generation.json
Normal file
14
tasks_gen/train/G1059/generation.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"id": "G1059",
|
||||
"pool": "train",
|
||||
"object_type": "CLAS",
|
||||
"category": "H",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100,
|
||||
"null": 30
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
43
tasks_gen/train/G1059/reference/sauna_pricer.clas.abap
Normal file
43
tasks_gen/train/G1059/reference/sauna_pricer.clas.abap
Normal file
@@ -0,0 +1,43 @@
|
||||
CLASS {{p}}sauna_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_sauna_price.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_min_days TYPE i VALUE 1,
|
||||
c_max_days TYPE i VALUE 14,
|
||||
c_min_guests TYPE i VALUE 1,
|
||||
c_max_guests TYPE i VALUE 10,
|
||||
c_many_guests TYPE i VALUE 6,
|
||||
c_rate_base TYPE {{p}}if_sauna_price=>ty_amount VALUE '120.00',
|
||||
c_rate_weekend TYPE {{p}}if_sauna_price=>ty_amount VALUE '150.00',
|
||||
c_rate_group TYPE {{p}}if_sauna_price=>ty_amount VALUE '140.00'.
|
||||
|
||||
METHODS rate_per_day
|
||||
IMPORTING iv_guests TYPE i
|
||||
iv_weekend TYPE abap_bool
|
||||
RETURNING VALUE(rv_rate) TYPE {{p}}if_sauna_price=>ty_amount.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}sauna_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_sauna_price~calculate.
|
||||
IF iv_days < c_min_days OR iv_days > c_max_days
|
||||
OR iv_guests < c_min_guests OR iv_guests > c_max_guests.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_price = rate_per_day( iv_guests = iv_guests
|
||||
iv_weekend = iv_weekend ) * iv_days.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rate_per_day.
|
||||
" Answer to the open question: the weekend rate has priority.
|
||||
IF iv_weekend = abap_true.
|
||||
rv_rate = c_rate_weekend.
|
||||
ELSEIF iv_guests > c_many_guests.
|
||||
rv_rate = c_rate_group.
|
||||
ELSE.
|
||||
rv_rate = c_rate_base.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,54 @@
|
||||
CLASS ltc_sauna_pricer DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_sauna_price.
|
||||
METHODS setup.
|
||||
METHODS base_hire FOR TESTING.
|
||||
METHODS weekend_hire FOR TESTING.
|
||||
METHODS group_hire FOR TESTING.
|
||||
METHODS weekend_group_hire FOR TESTING.
|
||||
METHODS too_many_days FOR TESTING.
|
||||
METHODS no_guests FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_sauna_pricer IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}sauna_pricer( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_hire.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_sauna_price=>ty_amount( '360.00' )
|
||||
act = mo_cut->calculate( iv_days = 3 iv_guests = 4 iv_weekend = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weekend_hire.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_sauna_price=>ty_amount( '300.00' )
|
||||
act = mo_cut->calculate( iv_days = 2 iv_guests = 4 iv_weekend = abap_true ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD group_hire.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_sauna_price=>ty_amount( '420.00' )
|
||||
act = mo_cut->calculate( iv_days = 3 iv_guests = 8 iv_weekend = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weekend_group_hire.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_sauna_price=>ty_amount( '300.00' )
|
||||
act = mo_cut->calculate( iv_days = 2 iv_guests = 8 iv_weekend = abap_true ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD too_many_days.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_sauna_price=>ty_amount( '0.00' )
|
||||
act = mo_cut->calculate( iv_days = 15 iv_guests = 4 iv_weekend = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD no_guests.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}if_sauna_price=>ty_amount( '0.00' )
|
||||
act = mo_cut->calculate( iv_days = 2 iv_guests = 0 iv_weekend = abap_false ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
8
tasks_gen/train/G1059/seed/if_sauna_price.intf.abap
Normal file
8
tasks_gen/train/G1059/seed/if_sauna_price.intf.abap
Normal file
@@ -0,0 +1,8 @@
|
||||
INTERFACE {{p}}if_sauna_price PUBLIC.
|
||||
TYPES ty_amount TYPE p LENGTH 11 DECIMALS 2.
|
||||
METHODS calculate
|
||||
IMPORTING iv_days TYPE i
|
||||
iv_guests TYPE i
|
||||
iv_weekend TYPE abap_bool
|
||||
RETURNING VALUE(rv_price) TYPE ty_amount.
|
||||
ENDINTERFACE.
|
||||
42
tasks_gen/train/G1059/spec.md
Normal file
42
tasks_gen/train/G1059/spec.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# 1. Goal
|
||||
Calculate the price of a hire of a mobile sauna trailer. A booking program calls
|
||||
the calculation before it confirms a booking. The price depends on the number of
|
||||
days, the number of guests and the day of the week.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The interface {{P}}IF_SAUNA_PRICE exists in package $TMP. It is active.
|
||||
- The interface has the type TY_AMOUNT (P length 11, 2 decimals) and one method:
|
||||
CALCULATE IMPORTING iv_days TYPE i, iv_guests TYPE i, iv_weekend TYPE abap_bool
|
||||
RETURNING VALUE(rv_price) TYPE ty_amount.
|
||||
- iv_weekend is abap_true when the hire starts on a Saturday or on a Sunday.
|
||||
|
||||
# 4. Contract
|
||||
- Create the class {{P}}SAUNA_PRICER in package $TMP.
|
||||
- The class is public, final, and has a public constructor without parameters.
|
||||
- The class implements {{P}}IF_SAUNA_PRICE.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
1. A hire has between 1 and 14 days. If iv_days is less than 1 or more than 14,
|
||||
return 0.
|
||||
2. A hire has between 1 and 10 guests. If iv_guests is less than 1 or more than
|
||||
10, return 0.
|
||||
3. The price of a hire is 120.00 EUR for each day.
|
||||
4. A weekend hire costs 150.00 EUR for each day.
|
||||
5. A hire with more than 6 guests costs 140.00 EUR for each day.
|
||||
6. The price of the hire is the price for each day multiplied by the number of
|
||||
days.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 8.16.
|
||||
- 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_SAUNA_PRICE.
|
||||
|
||||
# 7. Acceptance
|
||||
- The class is active and has no syntax error.
|
||||
- The price of each valid hire is correct.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
61
tasks_gen/train/G1059/task.json
Normal file
61
tasks_gen/train/G1059/task.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"id": "G1059",
|
||||
"category": "H",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "stop",
|
||||
"expected_gap": {
|
||||
"description": "Rules 4 and 5 give two different prices for each day (150.00 EUR and 140.00 EUR) for a hire that is both a weekend hire and has more than 6 guests, and the spec does not say which rule wins.",
|
||||
"keywords": [
|
||||
[
|
||||
"weekend",
|
||||
"guests"
|
||||
],
|
||||
[
|
||||
"weekend",
|
||||
"price"
|
||||
],
|
||||
[
|
||||
"guests",
|
||||
"price"
|
||||
]
|
||||
]
|
||||
},
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_SAUNA_PRICE",
|
||||
"file": "seed/if_sauna_price.intf.abap",
|
||||
"description": "Sauna hire price contract"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}SAUNA_PRICER",
|
||||
"implements": "{{P}}IF_SAUNA_PRICE"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}IF_SAUNA_PRICE"
|
||||
],
|
||||
"hidden_tests": [],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}SAUNA_PRICER",
|
||||
"file": "reference/sauna_pricer.clas.abap",
|
||||
"description": "Sauna hire price calculation",
|
||||
"testclasses_file": "reference/sauna_pricer.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"db_operation_in_loop"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user