Files
2026-10-05 18:02:52 +02:00

1.6 KiB

1. Goal

Calculate the price of a hire of a mobile sauna trailer. A booking program calls the calculation before it confirms a booking. The price depends on the number of days, the number of guests and the day of the week.

2. Open questions

None.

3. Context

  • The interface {{P}}IF_SAUNA_PRICE exists in package $TMP. It is active.
  • The interface has the type TY_AMOUNT (P length 11, 2 decimals) and one method: CALCULATE IMPORTING iv_days TYPE i, iv_guests TYPE i, iv_weekend TYPE abap_bool RETURNING VALUE(rv_price) TYPE ty_amount.
  • iv_weekend is abap_true when the hire starts on a Saturday or on a Sunday.

4. Contract

  • Create the class {{P}}SAUNA_PRICER in package $TMP.
  • The class is public, final, and has a public constructor without parameters.
  • The class implements {{P}}IF_SAUNA_PRICE.
  • Do not add other public methods.

5. Business rules

  1. A hire has between 1 and 14 days. If iv_days is less than 1 or more than 14, return 0.
  2. A hire has between 1 and 10 guests. If iv_guests is less than 1 or more than 10, return 0.
  3. The price of a hire is 120.00 EUR for each day.
  4. A weekend hire costs 150.00 EUR for each day.
  5. A hire with more than 6 guests costs 140.00 EUR for each day.
  6. The price of the hire is the price for each day multiplied by the number of days.

6. Constraints

  • Release target: 8.16.
  • 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_SAUNA_PRICE.

7. Acceptance

  • The class is active and has no syntax error.
  • The price of each valid hire is correct.
  • Write your own ABAP Unit tests for the class.