Files

1.7 KiB

1. Goal

Calculate the fare of a taxi trip. A dispatch program calls one function module for each completed trip. The function module must have the same interface as the sample function module, because the dispatch program calls all trip modules in the same way.

2. Open questions

None.

3. Context

  • Function group {{P}}FG_TAXI exists in package $TMP.
  • Function module {{P}}TAXI_SAMPLE exists in this group. It is the sample trip module. Its interface is the interface that all trip modules must use.

4. Contract

  • Create the function module {{P}}TAXI_FARE in function group {{P}}FG_TAXI.
  • Use exactly the interface of {{P}}TAXI_SAMPLE: the same parameter names, kinds, types, and exceptions.

5. Business rules

  1. If the distance is less than 0, raise the exception INVALID_DISTANCE.
  2. If the waiting time is less than 0, raise the exception INVALID_WAIT.
  3. The base fare is 3.50.
  4. The distance fare is 2.20 per kilometre for the first 10 kilometres. Every kilometre above 10 kilometres costs 1.80.
  5. The waiting time fare is 0.40 per minute.
  6. If the trip starts at or after 22:00:00, or before 06:00:00, multiply the sum of the base fare and the distance fare by 1.2. The waiting time fare is not multiplied.
  7. The total fare is the base fare plus the distance fare plus the waiting time fare, after rule 6.
  8. Round the total fare half up to 2 decimals.
  9. If the rounded total fare is less than 5.00, the fare is 5.00.

6. Constraints

  • Release target: 7.02. Do not use syntax that is newer than release 7.02.
  • Out of scope: do not change {{P}}TAXI_SAMPLE.

7. Acceptance

  • The function module is active and has no syntax error.
  • The hidden tests pass.
  • Write ABAP Unit tests for the function module in a global test class.