Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
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.
|
||||
Reference in New Issue
Block a user