2.2 KiB
2.2 KiB
1. Goal
A tour operator wants a summary of the booking fees of one day. The booking program calls one class for each day of the month and shows the summary.
2. Open questions
None.
3. Context
- The interface {{P}}IF_TOUR_SUMMARY exists in package $TMP. It is active.
- The interface has the types TY_TOUR_TYPE, TY_STATUS, TY_BOOKING, TT_BOOKING and TY_RESULT, the constant structure C_STATUS, and one method: SUMMARIZE IMPORTING it_bookings TYPE tt_booking RETURNING VALUE(rs_result) TYPE ty_result.
- The booking program passes the bookings of one day to the method.
- A day can have no bookings.
4. Contract
- Create the class {{P}}TOUR_SUMMARY in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class implements {{P}}IF_TOUR_SUMMARY.
- Do not add other public methods.
5. Business rules
- A tour type is 'C' (classic) or 'P' (premium).
- If one booking has a negative number of adults or a negative number of children, the summary is invalid. Return status 'N' and 0 in the fields total_fee, booking_count and average_fee.
- If one booking has a tour type that is not 'C' and not 'P', the summary is invalid. Return status 'T' and 0 in the fields total_fee, booking_count and average_fee.
- Check rule 2 before rule 3.
- The fee of one booking: an adult pays 20.00 for a classic tour and 30.00 for a premium tour. A child pays half of the adult fee of the tour.
- If the number of participants of one booking (adults plus children) is 10 or more, reduce the fee of this booking by 10 percent.
- Round the fee of each booking to 2 decimals. Round half up.
- total_fee is the sum of the fees of all bookings.
- booking_count is the number of bookings.
- average_fee is total_fee divided by booking_count. Round half up to 2 decimals.
- If the summary is valid, return status 'O'.
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_TOUR_SUMMARY.
7. Acceptance
- The class is active and has no syntax error.
- The class implements {{P}}IF_TOUR_SUMMARY.
- Write your own ABAP Unit tests for the class.