66 lines
2.8 KiB
Markdown
66 lines
2.8 KiB
Markdown
# 1. Goal
|
|
A drone delivery operator checks a delivery request before it releases a drone.
|
|
The dispatch program calls one check for each request. The program needs one
|
|
reason code for each request and the battery charge that the flight needs.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The interface {{P}}IF_DRONE_CHECK exists in package $TMP. It is active.
|
|
- The interface has the types TY_REASON (character, length 10), TY_WEIGHT
|
|
(packed number, length 8, 2 decimals), TY_DISTANCE (packed number, length 8,
|
|
2 decimals), TY_SPEED (packed number, length 8, 2 decimals) and TY_PERCENT
|
|
(integer).
|
|
- The interface has the constant structure C_REASON with the components OK,
|
|
PAYLOAD, DISTANCE, WIND, BATTERY, ZONE and LIGHT.
|
|
- The interface has one method:
|
|
CHECK
|
|
IMPORTING iv_payload TYPE ty_weight
|
|
iv_distance TYPE ty_distance
|
|
iv_wind_speed TYPE ty_speed
|
|
iv_battery TYPE ty_percent
|
|
iv_in_zone TYPE abap_bool
|
|
iv_daylight TYPE abap_bool
|
|
RETURNING VALUE(rv_reason) TYPE ty_reason.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}DRONE_CHECKER in package $TMP.
|
|
- The class is public, final, and has a public constructor without parameters.
|
|
- The class implements {{P}}IF_DRONE_CHECK.
|
|
- The class has the public method REQUIRED_BATTERY:
|
|
IMPORTING iv_distance TYPE {{P}}IF_DRONE_CHECK=>TY_DISTANCE
|
|
RETURNING VALUE(rv_percent) TYPE {{P}}IF_DRONE_CHECK=>TY_PERCENT.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
The payload is in kilograms, the distance in kilometres, the wind speed in
|
|
metres per second, and the battery charge in percent.
|
|
The check applies the rules in this sequence and returns the reason of the
|
|
first rule that fails.
|
|
1. If the payload is less than or equal to zero, or greater than 5.00, return
|
|
PAYLOAD.
|
|
2. If the distance is less than or equal to zero, or greater than 20.00, return
|
|
DISTANCE.
|
|
3. If the wind speed is greater than 12.00, return WIND.
|
|
4. If the battery charge is less than the charge that the flight needs, return
|
|
BATTERY.
|
|
5. If iv_in_zone is abap_false, return ZONE.
|
|
6. If iv_daylight is abap_false, return LIGHT.
|
|
7. Else return OK.
|
|
The charge that a flight needs is the result of REQUIRED_BATTERY:
|
|
- If the distance is less than or equal to zero, the result is 0.
|
|
- Else the result is 2 percent for each started kilometre plus a reserve of
|
|
10 percent. A started kilometre counts as a full kilometre.
|
|
|
|
# 6. Constraints
|
|
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
|
- 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_DRONE_CHECK.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|