2.1 KiB
2.1 KiB
1. Goal
Calculate the price of a jump session at a trampoline park. A booking program calls the calculation before it confirms a booking. The booking program needs one price in euro for each booking.
2. Open questions
None.
3. Context
- The trampoline park sells jump sessions of 30, 45, 60, 75 or 90 minutes.
- The booking program knows the number of persons in the booking, the length of the session in minutes, and if the customer has a member card.
- All prices are in euro and have 2 decimals.
4. Contract
- Create the class {{P}}JUMP_PRICER in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The public section has the type TY_AMOUNT (packed number, length 8, 2 decimals) and one method: CALCULATE IMPORTING iv_persons TYPE i iv_minutes TYPE i iv_member TYPE abap_bool RETURNING VALUE(rv_price) TYPE ty_amount.
- iv_persons is the number of persons. iv_minutes is the session length in minutes. iv_member is abap_true if the customer has a member card.
- Do not add other public methods.
5. Business rules
Apply the rules in this sequence.
- If iv_persons is less than 1, or iv_minutes is less than 1, the price is 0.00.
- The price per person depends on the session length:
- If the session is shorter than 60 minutes, the price per person is 8.00.
- If the session is longer than 60 minutes, the price per person is 12.00.
- Multiply the price per person by the number of persons.
- If iv_member is abap_true, subtract 20 percent from the result of rule 3.
- If the number of persons is 10 or more, subtract 10 percent from the result of rule 4.
- Round the result to 2 decimals. Round half up.
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 other objects in package $TMP.
7. Acceptance
- The class is active and has no syntax error.
- Every business rule is checked by a test.
- Write your own ABAP Unit tests for the class.