Files
abap-llm/tasks_gen/train/G1317/spec.md

19 lines
2.0 KiB
Markdown

Create the public final class {{P}}TOWING_FEE in package $TMP. The class has a public constructor without parameters. Define these public types: TY_STATUS (character field, length 8), TY_AMOUNT (integer), TY_CLASS (character field, length 1), and TY_RESULT (structure with components STATUS type TY_STATUS and FEE type TY_AMOUNT). Define the public constant structure C_STATUS with components OK, BAD_CLASS, BAD_DISTANCE, and BAD_HOUR. The values are 'OK', 'CLASS', 'DISTANCE', and 'HOUR'. The class has exactly one public method: CALCULATE, importing iv_vehicle_class TYPE ty_class, iv_distance_km TYPE i, iv_hour TYPE i, iv_is_weekend TYPE abap_bool, returning VALUE(rs_result) TYPE ty_result. Do not add other public methods.
The method CALCULATE applies these rules in this sequence:
1. Check the input. Return the status of the first check that fails. If a check fails, the fee is 0.
1.1 The vehicle class must be 'S', 'M', or 'L'. Else return BAD_CLASS.
1.2 The distance must be from 1 to 500 kilometres. Else return BAD_DISTANCE.
1.3 The hour must be from 0 to 23. Else return BAD_HOUR.
2. The base fee comes from the vehicle class: S = 60 EUR, M = 90 EUR, L = 140 EUR.
3. The distance charge: the first 10 kilometres are free. Each kilometre above 10 costs 2 EUR.
4. Add the base fee and the distance charge. The result is the subtotal.
5. The night is hour 22, hour 23, and hours 0 to 5. If the call is at night, calculate 25 percent of the subtotal. Round the night surcharge down to a full euro.
6. If the call is on a weekend, calculate 15 percent of the subtotal. Round the weekend surcharge down to a full euro. The night surcharge and the weekend surcharge can apply together. Calculate both surcharges from the subtotal.
7. Add the subtotal and all surcharges. The result is the total.
8. If the total is below 80 EUR, the total is 80 EUR.
9. Round the total up to a full 5 EUR. If the total is already a full 5 EUR, the total does not change.
10. Return the status OK and the fee.
Do not create other objects. Write ABAP Unit tests for the class.