Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
93
tasks_gen/train/G1042/faulty/m3_snow_fee.clas.abap
Normal file
93
tasks_gen/train/G1042/faulty/m3_snow_fee.clas.abap
Normal file
@@ -0,0 +1,93 @@
|
||||
CLASS {{p}}snow_fee DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES ty_area TYPE i.
|
||||
TYPES ty_priority TYPE c LENGTH 1.
|
||||
TYPES ty_distance TYPE i.
|
||||
TYPES ty_fee TYPE p LENGTH 9 DECIMALS 2.
|
||||
|
||||
METHODS calculate
|
||||
IMPORTING iv_area TYPE ty_area
|
||||
iv_priority TYPE ty_priority
|
||||
iv_distance TYPE ty_distance
|
||||
RETURNING VALUE(rv_fee) TYPE ty_fee.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_rate_small TYPE ty_fee VALUE '0.20',
|
||||
c_rate_medium TYPE ty_fee VALUE '0.16',
|
||||
c_rate_large TYPE ty_fee VALUE '0.12',
|
||||
c_rate_per_km TYPE ty_fee VALUE '0.40',
|
||||
c_minimum_fee TYPE ty_fee VALUE '45.00',
|
||||
c_free_km TYPE ty_distance VALUE 10,
|
||||
c_priority_expr TYPE ty_priority VALUE 'E',
|
||||
c_priority_emerg TYPE ty_priority VALUE 'X',
|
||||
c_factor_express TYPE i VALUE 125,
|
||||
c_factor_emergency TYPE i VALUE 150,
|
||||
c_factor_standard TYPE i VALUE 100,
|
||||
c_threshold_small TYPE ty_area VALUE 500,
|
||||
c_threshold_medium TYPE ty_area VALUE 2000.
|
||||
|
||||
METHODS base_fee
|
||||
IMPORTING iv_area TYPE ty_area
|
||||
iv_priority TYPE ty_priority
|
||||
RETURNING VALUE(rv_fee) TYPE ty_fee.
|
||||
METHODS rate_per_sqm
|
||||
IMPORTING iv_area TYPE ty_area
|
||||
RETURNING VALUE(rv_rate) TYPE ty_fee.
|
||||
METHODS surcharge_factor
|
||||
IMPORTING iv_priority TYPE ty_priority
|
||||
RETURNING VALUE(rv_factor) TYPE i.
|
||||
METHODS travel_cost
|
||||
IMPORTING iv_distance TYPE ty_distance
|
||||
RETURNING VALUE(rv_cost) TYPE ty_fee.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}snow_fee IMPLEMENTATION.
|
||||
METHOD calculate.
|
||||
IF iv_area <= 0.
|
||||
rv_fee = 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_fee = base_fee( iv_area = iv_area iv_priority = iv_priority )
|
||||
+ travel_cost( iv_distance = iv_distance ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_fee.
|
||||
DATA lv_amount TYPE ty_fee.
|
||||
lv_amount = iv_area * rate_per_sqm( iv_area ).
|
||||
IF lv_amount < c_minimum_fee.
|
||||
lv_amount = c_minimum_fee.
|
||||
ENDIF.
|
||||
rv_fee = lv_amount * surcharge_factor( iv_priority ) / 100.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rate_per_sqm.
|
||||
IF iv_area <= c_threshold_small.
|
||||
rv_rate = c_rate_small.
|
||||
ELSEIF iv_area > c_threshold_medium.
|
||||
rv_rate = c_rate_medium.
|
||||
ELSE.
|
||||
rv_rate = c_rate_large.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD surcharge_factor.
|
||||
CASE iv_priority.
|
||||
WHEN c_priority_expr.
|
||||
rv_factor = c_factor_express.
|
||||
WHEN c_priority_emerg.
|
||||
rv_factor = c_factor_emergency.
|
||||
WHEN OTHERS.
|
||||
rv_factor = c_factor_standard.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD travel_cost.
|
||||
DATA lv_chargeable_km TYPE ty_distance.
|
||||
lv_chargeable_km = iv_distance - c_free_km.
|
||||
IF lv_chargeable_km > 0.
|
||||
rv_cost = lv_chargeable_km * c_rate_per_km.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user