Step F first pass: 81/92 accepted; budget floor 60 calls; rejected slots moved for regeneration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
Kral
2026-10-03 12:10:52 +02:00
parent d3250acfb8
commit 39769afce8
741 changed files with 40573 additions and 317 deletions

View File

@@ -0,0 +1,73 @@
CLASS {{p}}vet_fee_calc DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES {{p}}if_vet_fee.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_base_fee,
species TYPE {{p}}if_vet_fee=>ty_species,
amount TYPE {{p}}if_vet_fee=>ty_amount,
END OF ty_base_fee,
tt_base_fee TYPE HASHED TABLE OF ty_base_fee WITH UNIQUE KEY species.
CONSTANTS:
c_free_kg TYPE i VALUE 5,
c_max_kg TYPE i VALUE 200,
c_fee_per_kg TYPE {{p}}if_vet_fee=>ty_amount VALUE '2.00'.
METHODS normalize_species
IMPORTING iv_species TYPE {{p}}if_vet_fee=>ty_species
RETURNING VALUE(rv_species) TYPE {{p}}if_vet_fee=>ty_species.
METHODS base_fees
RETURNING VALUE(rt_base_fee) TYPE tt_base_fee.
METHODS medication_fee
IMPORTING iv_weight TYPE {{p}}if_vet_fee=>ty_weight
RETURNING VALUE(rv_fee) TYPE {{p}}if_vet_fee=>ty_amount.
ENDCLASS.
CLASS {{p}}vet_fee_calc IMPLEMENTATION.
METHOD {{p}}if_vet_fee~calculate.
DATA(lv_species) = normalize_species( iv_species ).
DATA(lt_base_fee) = base_fees( ).
ASSIGN lt_base_fee[ species = lv_species ] TO FIELD-SYMBOL(<ls_base_fee>).
IF sy-subrc <> 0.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-species ).
RETURN.
ENDIF.
IF iv_weight <= 0 AND iv_weight > c_max_kg.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-weight ).
RETURN.
ENDIF.
DATA(lv_medication) = medication_fee( iv_weight ).
DATA lv_fee TYPE {{p}}if_vet_fee=>ty_amount.
lv_fee = <ls_base_fee>-amount + lv_medication.
IF iv_emergency = abap_true.
lv_fee = lv_fee + <ls_base_fee>-amount / 2.
ENDIF.
IF iv_registered = abap_true.
lv_fee = lv_fee - ( <ls_base_fee>-amount + lv_medication ) / 10.
ENDIF.
rs_result = VALUE #( fee = lv_fee reason = {{p}}if_vet_fee=>c_reason-ok ).
ENDMETHOD.
METHOD normalize_species.
rv_species = to_upper( replace( val = iv_species sub = ` ` with = `` occ = 0 ) ).
ENDMETHOD.
METHOD base_fees.
rt_base_fee = VALUE #( ( species = 'DOG' amount = '45.00' )
( species = 'CAT' amount = '35.00' )
( species = 'RABBIT' amount = '25.00' )
( species = 'BIRD' amount = '18.00' )
( species = 'REPTILE' amount = '30.00' ) ).
ENDMETHOD.
METHOD medication_fee.
DATA lv_kg TYPE i.
lv_kg = ceil( iv_weight - c_free_kg ).
IF lv_kg > 0.
rv_fee = lv_kg * c_fee_per_kg.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,73 @@
CLASS {{p}}vet_fee_calc DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES {{p}}if_vet_fee.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_base_fee,
species TYPE {{p}}if_vet_fee=>ty_species,
amount TYPE {{p}}if_vet_fee=>ty_amount,
END OF ty_base_fee,
tt_base_fee TYPE HASHED TABLE OF ty_base_fee WITH UNIQUE KEY species.
CONSTANTS:
c_free_kg TYPE i VALUE 5,
c_max_kg TYPE i VALUE 200,
c_fee_per_kg TYPE {{p}}if_vet_fee=>ty_amount VALUE '2.00'.
METHODS normalize_species
IMPORTING iv_species TYPE {{p}}if_vet_fee=>ty_species
RETURNING VALUE(rv_species) TYPE {{p}}if_vet_fee=>ty_species.
METHODS base_fees
RETURNING VALUE(rt_base_fee) TYPE tt_base_fee.
METHODS medication_fee
IMPORTING iv_weight TYPE {{p}}if_vet_fee=>ty_weight
RETURNING VALUE(rv_fee) TYPE {{p}}if_vet_fee=>ty_amount.
ENDCLASS.
CLASS {{p}}vet_fee_calc IMPLEMENTATION.
METHOD {{p}}if_vet_fee~calculate.
DATA(lv_species) = normalize_species( iv_species ).
DATA(lt_base_fee) = base_fees( ).
ASSIGN lt_base_fee[ species = lv_species ] TO FIELD-SYMBOL(<ls_base_fee>).
IF sy-subrc <> 0.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-species ).
RETURN.
ENDIF.
IF iv_weight <= 0 OR iv_weight > c_max_kg.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-weight ).
RETURN.
ENDIF.
DATA(lv_medication) = medication_fee( iv_weight ).
DATA lv_fee TYPE {{p}}if_vet_fee=>ty_amount.
lv_fee = <ls_base_fee>-amount + lv_medication.
IF iv_emergency = abap_false.
lv_fee = lv_fee + <ls_base_fee>-amount / 2.
ENDIF.
IF iv_registered = abap_true.
lv_fee = lv_fee - ( <ls_base_fee>-amount + lv_medication ) / 10.
ENDIF.
rs_result = VALUE #( fee = lv_fee reason = {{p}}if_vet_fee=>c_reason-ok ).
ENDMETHOD.
METHOD normalize_species.
rv_species = to_upper( replace( val = iv_species sub = ` ` with = `` occ = 0 ) ).
ENDMETHOD.
METHOD base_fees.
rt_base_fee = VALUE #( ( species = 'DOG' amount = '45.00' )
( species = 'CAT' amount = '35.00' )
( species = 'RABBIT' amount = '25.00' )
( species = 'BIRD' amount = '18.00' )
( species = 'REPTILE' amount = '30.00' ) ).
ENDMETHOD.
METHOD medication_fee.
DATA lv_kg TYPE i.
lv_kg = ceil( iv_weight - c_free_kg ).
IF lv_kg > 0.
rv_fee = lv_kg * c_fee_per_kg.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,73 @@
CLASS {{p}}vet_fee_calc DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES {{p}}if_vet_fee.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_base_fee,
species TYPE {{p}}if_vet_fee=>ty_species,
amount TYPE {{p}}if_vet_fee=>ty_amount,
END OF ty_base_fee,
tt_base_fee TYPE HASHED TABLE OF ty_base_fee WITH UNIQUE KEY species.
CONSTANTS:
c_free_kg TYPE i VALUE 5,
c_max_kg TYPE i VALUE 200,
c_fee_per_kg TYPE {{p}}if_vet_fee=>ty_amount VALUE '2.00'.
METHODS normalize_species
IMPORTING iv_species TYPE {{p}}if_vet_fee=>ty_species
RETURNING VALUE(rv_species) TYPE {{p}}if_vet_fee=>ty_species.
METHODS base_fees
RETURNING VALUE(rt_base_fee) TYPE tt_base_fee.
METHODS medication_fee
IMPORTING iv_weight TYPE {{p}}if_vet_fee=>ty_weight
RETURNING VALUE(rv_fee) TYPE {{p}}if_vet_fee=>ty_amount.
ENDCLASS.
CLASS {{p}}vet_fee_calc IMPLEMENTATION.
METHOD {{p}}if_vet_fee~calculate.
DATA(lv_species) = normalize_species( iv_species ).
DATA(lt_base_fee) = base_fees( ).
ASSIGN lt_base_fee[ species = lv_species ] TO FIELD-SYMBOL(<ls_base_fee>).
IF sy-subrc <> 0.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-species ).
RETURN.
ENDIF.
IF iv_weight <= 0 OR iv_weight > c_max_kg.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-weight ).
RETURN.
ENDIF.
DATA(lv_medication) = medication_fee( iv_weight ).
DATA lv_fee TYPE {{p}}if_vet_fee=>ty_amount.
lv_fee = <ls_base_fee>-amount + lv_medication.
IF iv_emergency = abap_true.
lv_fee = lv_fee + <ls_base_fee>-amount / 2.
ENDIF.
IF iv_registered <> abap_true.
lv_fee = lv_fee - ( <ls_base_fee>-amount + lv_medication ) / 10.
ENDIF.
rs_result = VALUE #( fee = lv_fee reason = {{p}}if_vet_fee=>c_reason-ok ).
ENDMETHOD.
METHOD normalize_species.
rv_species = to_upper( replace( val = iv_species sub = ` ` with = `` occ = 0 ) ).
ENDMETHOD.
METHOD base_fees.
rt_base_fee = VALUE #( ( species = 'DOG' amount = '45.00' )
( species = 'CAT' amount = '35.00' )
( species = 'RABBIT' amount = '25.00' )
( species = 'BIRD' amount = '18.00' )
( species = 'REPTILE' amount = '30.00' ) ).
ENDMETHOD.
METHOD medication_fee.
DATA lv_kg TYPE i.
lv_kg = ceil( iv_weight - c_free_kg ).
IF lv_kg > 0.
rv_fee = lv_kg * c_fee_per_kg.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,73 @@
CLASS {{p}}vet_fee_calc DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES {{p}}if_vet_fee.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_base_fee,
species TYPE {{p}}if_vet_fee=>ty_species,
amount TYPE {{p}}if_vet_fee=>ty_amount,
END OF ty_base_fee,
tt_base_fee TYPE HASHED TABLE OF ty_base_fee WITH UNIQUE KEY species.
CONSTANTS:
c_free_kg TYPE i VALUE 5,
c_max_kg TYPE i VALUE 200,
c_fee_per_kg TYPE {{p}}if_vet_fee=>ty_amount VALUE '2.00'.
METHODS normalize_species
IMPORTING iv_species TYPE {{p}}if_vet_fee=>ty_species
RETURNING VALUE(rv_species) TYPE {{p}}if_vet_fee=>ty_species.
METHODS base_fees
RETURNING VALUE(rt_base_fee) TYPE tt_base_fee.
METHODS medication_fee
IMPORTING iv_weight TYPE {{p}}if_vet_fee=>ty_weight
RETURNING VALUE(rv_fee) TYPE {{p}}if_vet_fee=>ty_amount.
ENDCLASS.
CLASS {{p}}vet_fee_calc IMPLEMENTATION.
METHOD {{p}}if_vet_fee~calculate.
DATA(lv_species) = normalize_species( iv_species ).
DATA(lt_base_fee) = base_fees( ).
ASSIGN lt_base_fee[ species = lv_species ] TO FIELD-SYMBOL(<ls_base_fee>).
IF sy-subrc <> 0.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-species ).
RETURN.
ENDIF.
IF iv_weight <= 0 OR iv_weight > c_max_kg.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-weight ).
RETURN.
ENDIF.
DATA(lv_medication) = medication_fee( iv_weight ).
DATA lv_fee TYPE {{p}}if_vet_fee=>ty_amount.
lv_fee = <ls_base_fee>-amount + lv_medication.
IF iv_emergency = abap_true.
lv_fee = lv_fee + <ls_base_fee>-amount / 2.
ENDIF.
IF iv_registered = abap_true.
lv_fee = lv_fee + ( <ls_base_fee>-amount + lv_medication ) / 10.
ENDIF.
rs_result = VALUE #( fee = lv_fee reason = {{p}}if_vet_fee=>c_reason-ok ).
ENDMETHOD.
METHOD normalize_species.
rv_species = to_upper( replace( val = iv_species sub = ` ` with = `` occ = 0 ) ).
ENDMETHOD.
METHOD base_fees.
rt_base_fee = VALUE #( ( species = 'DOG' amount = '45.00' )
( species = 'CAT' amount = '35.00' )
( species = 'RABBIT' amount = '25.00' )
( species = 'BIRD' amount = '18.00' )
( species = 'REPTILE' amount = '30.00' ) ).
ENDMETHOD.
METHOD medication_fee.
DATA lv_kg TYPE i.
lv_kg = ceil( iv_weight - c_free_kg ).
IF lv_kg > 0.
rv_fee = lv_kg * c_fee_per_kg.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,73 @@
CLASS {{p}}vet_fee_calc DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES {{p}}if_vet_fee.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_base_fee,
species TYPE {{p}}if_vet_fee=>ty_species,
amount TYPE {{p}}if_vet_fee=>ty_amount,
END OF ty_base_fee,
tt_base_fee TYPE HASHED TABLE OF ty_base_fee WITH UNIQUE KEY species.
CONSTANTS:
c_free_kg TYPE i VALUE 5,
c_max_kg TYPE i VALUE 200,
c_fee_per_kg TYPE {{p}}if_vet_fee=>ty_amount VALUE '2.00'.
METHODS normalize_species
IMPORTING iv_species TYPE {{p}}if_vet_fee=>ty_species
RETURNING VALUE(rv_species) TYPE {{p}}if_vet_fee=>ty_species.
METHODS base_fees
RETURNING VALUE(rt_base_fee) TYPE tt_base_fee.
METHODS medication_fee
IMPORTING iv_weight TYPE {{p}}if_vet_fee=>ty_weight
RETURNING VALUE(rv_fee) TYPE {{p}}if_vet_fee=>ty_amount.
ENDCLASS.
CLASS {{p}}vet_fee_calc IMPLEMENTATION.
METHOD {{p}}if_vet_fee~calculate.
DATA(lv_species) = normalize_species( iv_species ).
DATA(lt_base_fee) = base_fees( ).
ASSIGN lt_base_fee[ species = lv_species ] TO FIELD-SYMBOL(<ls_base_fee>).
IF sy-subrc <> 0.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-species ).
RETURN.
ENDIF.
IF iv_weight <= 0 OR iv_weight > c_max_kg.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-weight ).
RETURN.
ENDIF.
DATA(lv_medication) = medication_fee( iv_weight ).
DATA lv_fee TYPE {{p}}if_vet_fee=>ty_amount.
lv_fee = <ls_base_fee>-amount + lv_medication.
IF iv_emergency = abap_true.
lv_fee = lv_fee + <ls_base_fee>-amount / 2.
ENDIF.
IF iv_registered = abap_true.
lv_fee = lv_fee - ( <ls_base_fee>-amount + lv_medication ) / 10.
ENDIF.
rs_result = VALUE #( fee = lv_fee reason = {{p}}if_vet_fee=>c_reason-ok ).
ENDMETHOD.
METHOD normalize_species.
rv_species = to_upper( replace( val = iv_species sub = ` ` with = `` occ = 0 ) ).
ENDMETHOD.
METHOD base_fees.
rt_base_fee = VALUE #( ( species = 'DOG' amount = '45.00' )
( species = 'CAT' amount = '35.00' )
( species = 'RABBIT' amount = '25.00' )
( species = 'BIRD' amount = '18.00' )
( species = 'REPTILE' amount = '30.00' ) ).
ENDMETHOD.
METHOD medication_fee.
DATA lv_kg TYPE i.
lv_kg = ceil( iv_weight - c_free_kg ).
IF lv_kg <= 0.
rv_fee = lv_kg * c_fee_per_kg.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,19 @@
{
"id": "G0150",
"pool": "eval",
"object_type": "CLAS",
"category": "F",
"attempts": [
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 5,
"killed": 5,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,171 @@
CLASS {{p}}vet_fee_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}if_vet_fee.
METHODS setup.
METHODS assert_fee
IMPORTING iv_expected TYPE {{p}}if_vet_fee=>ty_amount
iv_actual TYPE {{p}}if_vet_fee=>ty_amount.
METHODS dog_base_fee FOR TESTING.
METHODS medication_started_kg FOR TESTING.
METHODS no_medication_at_five_kg FOR TESTING.
METHODS emergency_surcharge FOR TESTING.
METHODS registered_discount FOR TESTING.
METHODS combined_charges FOR TESTING.
METHODS unknown_species FOR TESTING.
METHODS species_lower_case FOR TESTING.
METHODS zero_weight FOR TESTING.
METHODS weight_limit_checked FOR TESTING.
METHODS species_before_weight FOR TESTING.
METHODS bird_and_reptile_base FOR TESTING.
ENDCLASS.
CLASS {{p}}vet_fee_hidden IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}vet_fee_calc( ).
ENDMETHOD.
METHOD assert_fee.
cl_abap_unit_assert=>assert_equals( exp = iv_expected act = iv_actual ).
ENDMETHOD.
METHOD dog_base_fee.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'DOG'
iv_weight = '5.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '45.00' iv_actual = ls_result-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-ok
act = ls_result-reason ).
ENDMETHOD.
METHOD medication_started_kg.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'DOG'
iv_weight = '7.001'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '51.00' iv_actual = ls_result-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-ok
act = ls_result-reason ).
ENDMETHOD.
METHOD no_medication_at_five_kg.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'CAT'
iv_weight = '5.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '35.00' iv_actual = ls_result-fee ).
ENDMETHOD.
METHOD emergency_surcharge.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'DOG'
iv_weight = '5.000'
iv_emergency = abap_true
iv_registered = abap_false ).
assert_fee( iv_expected = '67.50' iv_actual = ls_result-fee ).
ENDMETHOD.
METHOD registered_discount.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'CAT'
iv_weight = '5.000'
iv_emergency = abap_false
iv_registered = abap_true ).
assert_fee( iv_expected = '31.50' iv_actual = ls_result-fee ).
ENDMETHOD.
METHOD combined_charges.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'RABBIT'
iv_weight = '6.500'
iv_emergency = abap_true
iv_registered = abap_true ).
assert_fee( iv_expected = '38.60' iv_actual = ls_result-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-ok
act = ls_result-reason ).
ENDMETHOD.
METHOD unknown_species.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'HORSE'
iv_weight = '10.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '0.00' iv_actual = ls_result-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-species
act = ls_result-reason ).
ENDMETHOD.
METHOD species_lower_case.
DATA(ls_result) = mo_cut->calculate(
iv_species = ' dog '
iv_weight = '5.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '45.00' iv_actual = ls_result-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-ok
act = ls_result-reason ).
ENDMETHOD.
METHOD zero_weight.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'DOG'
iv_weight = '0.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '0.00' iv_actual = ls_result-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-weight
act = ls_result-reason ).
ENDMETHOD.
METHOD weight_limit_checked.
DATA(ls_ok) = mo_cut->calculate(
iv_species = 'DOG'
iv_weight = '200.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '435.00' iv_actual = ls_ok-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-ok
act = ls_ok-reason ).
DATA(ls_heavy) = mo_cut->calculate(
iv_species = 'DOG'
iv_weight = '200.001'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '0.00' iv_actual = ls_heavy-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-weight
act = ls_heavy-reason ).
ENDMETHOD.
METHOD species_before_weight.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'HORSE'
iv_weight = '0.000'
iv_emergency = abap_false
iv_registered = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-species
act = ls_result-reason ).
ENDMETHOD.
METHOD bird_and_reptile_base.
DATA(ls_bird) = mo_cut->calculate(
iv_species = 'BIRD'
iv_weight = '5.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '18.00' iv_actual = ls_bird-fee ).
DATA(ls_reptile) = mo_cut->calculate(
iv_species = 'REPTILE'
iv_weight = '5.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '30.00' iv_actual = ls_reptile-fee ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,74 @@
{
"task": "G0150",
"mutants": [
{
"object": "{{P}}VET_FEE_CALC",
"mutant": "line 38: OR -> AND (logic)",
"status": "killed",
"hidden": "10/12",
"failed_tests": [
"WEIGHT_LIMIT_CHECKED",
"ZERO_WEIGHT"
]
},
{
"object": "{{P}}VET_FEE_CALC",
"mutant": "line 45: abap_true -> abap_false (bool)",
"status": "killed",
"hidden": "3/12",
"failed_tests": [
"BIRD_AND_REPTILE_BASE",
"COMBINED_CHARGES",
"DOG_BASE_FEE",
"EMERGENCY_SURCHARGE",
"MEDICATION_STARTED_KG",
"NO_MEDICATION_AT_FIVE_KG",
"REGISTERED_DISCOUNT",
"SPECIES_LOWER_CASE",
"WEIGHT_LIMIT_CHECKED"
]
},
{
"object": "{{P}}VET_FEE_CALC",
"mutant": "line 48: = -> <> (eq)",
"status": "killed",
"hidden": "3/12",
"failed_tests": [
"BIRD_AND_REPTILE_BASE",
"COMBINED_CHARGES",
"DOG_BASE_FEE",
"EMERGENCY_SURCHARGE",
"MEDICATION_STARTED_KG",
"NO_MEDICATION_AT_FIVE_KG",
"REGISTERED_DISCOUNT",
"SPECIES_LOWER_CASE",
"WEIGHT_LIMIT_CHECKED"
]
},
{
"object": "{{P}}VET_FEE_CALC",
"mutant": "line 49: - -> + (arith)",
"status": "killed",
"hidden": "10/12",
"failed_tests": [
"COMBINED_CHARGES",
"REGISTERED_DISCOUNT"
]
},
{
"object": "{{P}}VET_FEE_CALC",
"mutant": "line 69: > -> <= (rel)",
"status": "killed",
"hidden": "9/12",
"failed_tests": [
"COMBINED_CHARGES",
"MEDICATION_STARTED_KG",
"WEIGHT_LIMIT_CHECKED"
]
}
],
"valid": 5,
"killed": 5,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,73 @@
CLASS {{p}}vet_fee_calc DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES {{p}}if_vet_fee.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_base_fee,
species TYPE {{p}}if_vet_fee=>ty_species,
amount TYPE {{p}}if_vet_fee=>ty_amount,
END OF ty_base_fee,
tt_base_fee TYPE HASHED TABLE OF ty_base_fee WITH UNIQUE KEY species.
CONSTANTS:
c_free_kg TYPE i VALUE 5,
c_max_kg TYPE i VALUE 200,
c_fee_per_kg TYPE {{p}}if_vet_fee=>ty_amount VALUE '2.00'.
METHODS normalize_species
IMPORTING iv_species TYPE {{p}}if_vet_fee=>ty_species
RETURNING VALUE(rv_species) TYPE {{p}}if_vet_fee=>ty_species.
METHODS base_fees
RETURNING VALUE(rt_base_fee) TYPE tt_base_fee.
METHODS medication_fee
IMPORTING iv_weight TYPE {{p}}if_vet_fee=>ty_weight
RETURNING VALUE(rv_fee) TYPE {{p}}if_vet_fee=>ty_amount.
ENDCLASS.
CLASS {{p}}vet_fee_calc IMPLEMENTATION.
METHOD {{p}}if_vet_fee~calculate.
DATA(lv_species) = normalize_species( iv_species ).
DATA(lt_base_fee) = base_fees( ).
ASSIGN lt_base_fee[ species = lv_species ] TO FIELD-SYMBOL(<ls_base_fee>).
IF sy-subrc <> 0.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-species ).
RETURN.
ENDIF.
IF iv_weight <= 0 OR iv_weight > c_max_kg.
rs_result = VALUE #( reason = {{p}}if_vet_fee=>c_reason-weight ).
RETURN.
ENDIF.
DATA(lv_medication) = medication_fee( iv_weight ).
DATA lv_fee TYPE {{p}}if_vet_fee=>ty_amount.
lv_fee = <ls_base_fee>-amount + lv_medication.
IF iv_emergency = abap_true.
lv_fee = lv_fee + <ls_base_fee>-amount / 2.
ENDIF.
IF iv_registered = abap_true.
lv_fee = lv_fee - ( <ls_base_fee>-amount + lv_medication ) / 10.
ENDIF.
rs_result = VALUE #( fee = lv_fee reason = {{p}}if_vet_fee=>c_reason-ok ).
ENDMETHOD.
METHOD normalize_species.
rv_species = to_upper( replace( val = iv_species sub = ` ` with = `` occ = 0 ) ).
ENDMETHOD.
METHOD base_fees.
rt_base_fee = VALUE #( ( species = 'DOG' amount = '45.00' )
( species = 'CAT' amount = '35.00' )
( species = 'RABBIT' amount = '25.00' )
( species = 'BIRD' amount = '18.00' )
( species = 'REPTILE' amount = '30.00' ) ).
ENDMETHOD.
METHOD medication_fee.
DATA lv_kg TYPE i.
lv_kg = ceil( iv_weight - c_free_kg ).
IF lv_kg > 0.
rv_fee = lv_kg * c_fee_per_kg.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,85 @@
CLASS ltc_vet_fee_calc DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}if_vet_fee.
METHODS setup.
METHODS assert_fee
IMPORTING iv_expected TYPE {{p}}if_vet_fee=>ty_amount
iv_actual TYPE {{p}}if_vet_fee=>ty_amount.
METHODS dog_visit FOR TESTING.
METHODS medication_for_started_kg FOR TESTING.
METHODS emergency_visit FOR TESTING.
METHODS registered_patient FOR TESTING.
METHODS unknown_species FOR TESTING.
METHODS invalid_weight FOR TESTING.
ENDCLASS.
CLASS ltc_vet_fee_calc IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}vet_fee_calc( ).
ENDMETHOD.
METHOD assert_fee.
cl_abap_unit_assert=>assert_equals( exp = iv_expected act = iv_actual ).
ENDMETHOD.
METHOD dog_visit.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'DOG'
iv_weight = '5.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '45.00' iv_actual = ls_result-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-ok
act = ls_result-reason ).
ENDMETHOD.
METHOD medication_for_started_kg.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'DOG'
iv_weight = '7.001'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '51.00' iv_actual = ls_result-fee ).
ENDMETHOD.
METHOD emergency_visit.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'DOG'
iv_weight = '5.000'
iv_emergency = abap_true
iv_registered = abap_false ).
assert_fee( iv_expected = '67.50' iv_actual = ls_result-fee ).
ENDMETHOD.
METHOD registered_patient.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'CAT'
iv_weight = '5.000'
iv_emergency = abap_false
iv_registered = abap_true ).
assert_fee( iv_expected = '31.50' iv_actual = ls_result-fee ).
ENDMETHOD.
METHOD unknown_species.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'HORSE'
iv_weight = '10.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '0.00' iv_actual = ls_result-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-species
act = ls_result-reason ).
ENDMETHOD.
METHOD invalid_weight.
DATA(ls_result) = mo_cut->calculate(
iv_species = 'DOG'
iv_weight = '250.000'
iv_emergency = abap_false
iv_registered = abap_false ).
assert_fee( iv_expected = '0.00' iv_actual = ls_result-fee ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_vet_fee=>c_reason-weight
act = ls_result-reason ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,27 @@
INTERFACE {{p}}if_vet_fee PUBLIC.
TYPES:
ty_species TYPE c LENGTH 8,
ty_weight TYPE p LENGTH 7 DECIMALS 3,
ty_amount TYPE p LENGTH 9 DECIMALS 2,
ty_reason TYPE c LENGTH 10.
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',
species TYPE ty_reason VALUE 'SPECIES',
weight TYPE ty_reason VALUE 'WEIGHT',
END OF c_reason.
METHODS calculate
IMPORTING iv_species TYPE ty_species
iv_weight TYPE ty_weight
iv_emergency TYPE abap_bool
iv_registered TYPE abap_bool
RETURNING VALUE(rs_result) TYPE ty_result.
ENDINTERFACE.

View File

@@ -0,0 +1,53 @@
# 1. Goal
Calculate the consultation fee of a visit at a veterinary clinic. A clinic program
calls the calculation before it prints the invoice. The program needs the fee and
one reason code for each visit.
# 2. Open questions
None.
# 3. Context
- The interface {{P}}IF_VET_FEE exists in package $TMP. It is active. Read the
interface. It contains the types, the constants and the method signature that
the calculation uses.
- The interface is not part of this task.
# 4. Contract
- Create the class {{P}}VET_FEE_CALC in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class implements {{P}}IF_VET_FEE.
- Do not add other public methods.
# 5. Business rules
The rules run in this sequence. Rules 1 to 3 prepare and check the input.
Rules 4 to 8 calculate the fee.
1. Remove all spaces from the species. Convert all letters to upper case.
2. The species must be DOG, CAT, RABBIT, BIRD or REPTILE. If not, the
calculation returns the reason SPECIES and a fee of 0.
3. The weight must be above 0 kg and at most 200 kg. If not, the calculation
returns the reason WEIGHT and a fee of 0.
4. The base fee depends on the species:
DOG 45.00, CAT 35.00, RABBIT 25.00, BIRD 18.00, REPTILE 30.00.
5. The medication fee is 2.00 for each started kilogram of weight above 5 kg.
Examples: 5.000 kg gives 0.00, 5.001 kg gives 2.00, 7.000 kg gives 4.00,
7.001 kg gives 6.00.
6. If the visit is an emergency, add half of the base fee. For a dog the
surcharge is 22.50.
7. If the animal is a registered patient of the clinic, subtract 10 percent of
the base fee plus the medication fee. The emergency surcharge is not part of
the discount. The base fee plus the medication fee is always a whole number
of euro, so the discount has at most one decimal place.
8. The fee is the base fee plus the medication fee plus the emergency surcharge
minus the registered discount. The calculation returns the reason OK and
this fee.
# 6. Constraints
- Release target: 7.58.
- 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_VET_FEE.
# 7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.

View File

@@ -0,0 +1,51 @@
{
"id": "G0150",
"category": "F",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v758",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "INTF",
"name": "{{P}}IF_VET_FEE",
"file": "seed/if_vet_fee.intf.abap",
"description": "Veterinary consultation fee contract; the model must read it"
}
],
"contract": [
{
"type": "CLAS",
"name": "{{P}}VET_FEE_CALC",
"implements": "{{P}}IF_VET_FEE"
}
],
"out_of_scope": [
"{{P}}IF_VET_FEE"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}VET_FEE_HIDDEN",
"file": "hidden/vet_fee_hidden.clas.abap",
"description": "T41 hidden tests"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}VET_FEE_CALC",
"file": "reference/vet_fee_calc.clas.abap",
"description": "Veterinary consultation fee calculator",
"testclasses_file": "reference/vet_fee_calc.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"clean_abap"
]
}