2.4 KiB
2.4 KiB
1. Goal
A tool hire shop rents power tools to its customers. The checkout program calls the class {{P}}TOOL_HIRE for each hire request before it prints the hire contract. The program needs the fee of the hire and one reason code.
2. Open questions
None.
3. Context
- Interface {{P}}IF_TOOL_HIRE exists in package $TMP. It is active.
- The interface has these types: TY_TOOL (CHAR 1), TY_DAYS (integer), TY_AMOUNT (packed, 13 digits, 2 decimals), TY_REASON (CHAR 12).
- The interface has the structure TY_RESULT with the components FEE and REASON.
- The interface has the constant structure C_REASON with the values OK, UNKNOWN_TOOL and TOO_SHORT.
- The interface has one method: CALCULATE IMPORTING iv_tool TYPE ty_tool iv_days TYPE ty_days RETURNING VALUE(rs_result) TYPE ty_result.
4. Contract
- Create the class {{P}}TOOL_HIRE in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class implements {{P}}IF_TOOL_HIRE.
- Do not add other public methods.
5. Business rules
- The tool category is one character. These categories exist: 'D' is a drill, 'S' is a sander, 'C' is a tile cutter. Every other category is unknown. For an unknown category return the reason UNKNOWN_TOOL and the fee 0.00.
- A hire of less than 1 day is not possible. Return the reason TOO_SHORT and the fee 0.00.
- The daily rate is 12.00 for 'D', 9.00 for 'S' and 15.00 for 'C'. A hire of 1 to 6 days costs the daily rate multiplied by the number of days.
- A hire of 7 days or more costs the weekly rate instead of the daily rate. The weekly rate is 60.00 for 'D', 45.00 for 'S' and 75.00 for 'C'.
- A hire of 28 days or more costs the monthly rate instead of the weekly rate. The monthly rate is 180.00 for 'D', 135.00 for 'S' and 225.00 for 'C'.
- The shop accepts hires of at most 90 days.
- For every accepted hire return the reason OK and the fee of the hire.
- The checkout program calls the class for every hire request, also for requests that the shop cannot accept.
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_TOOL_HIRE.
7. Acceptance
- The class is active and has no syntax error.
- Write your own ABAP Unit tests for the class.