Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
1.9 KiB
1.9 KiB
1. Goal
Calculate the price of a booking at a recording studio. A booking program calls the calculation before it shows the price to the customer. The program needs one price for each booking.
2. Open questions
None.
3. Context
- The interface {{P}}IF_STUDIO_PRICER exists in package $TMP. It is active.
- The interface has the type TY_ROOM (CHAR 1), the type TY_AMOUNT (packed, length 8, 2 decimals), the constant structure C_ROOM (A, B, C), and one method: CALCULATE IMPORTING iv_room TYPE ty_room, iv_minutes TYPE i, iv_bookings TYPE i RETURNING VALUE(rv_price) TYPE ty_amount.
4. Contract
- Create the class {{P}}STUDIO_PRICER in package $TMP.
- The class is public and final. It has a public constructor without parameters.
- The class implements {{P}}IF_STUDIO_PRICER.
- Do not add other public methods.
5. Business rules
Apply the rules in this sequence.
- The room type is A, B, or C. Any other room type is invalid. For an invalid room type, return 0.00.
- The hourly rate depends on the room type: A 48.00, B 36.00, C 27.00.
- The booking duration is given in minutes. A started hour counts as a full hour. A booking of less than 60 minutes counts as one hour.
- The base price is the hourly rate multiplied by the number of hours.
- The loyalty discount is 0.75 percent for each booking of the customer in the last 12 months. The discount is at most 15 percent.
- The discount percentage is rounded.
- The price is the base price minus the discount. The discount is the rounded discount percentage of the base price.
- Return the price.
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_STUDIO_PRICER.
7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.