71 lines
2.9 KiB
Markdown
71 lines
2.9 KiB
Markdown
# 1. Goal
|
|
A leisure centre prices the entry tickets of its swimming pool. The ticket
|
|
desk calls the class for each visitor and prints the price. The desk also needs
|
|
one status code for each booking request.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- No object of this task exists yet. Create everything that the contract lists.
|
|
- The leisure centre has four areas. Their area codes are IN (indoor pool),
|
|
OU (outdoor pool), SA (sauna area) and AL (all areas).
|
|
- The visitor rates are A (adult), C (child) and S (senior).
|
|
- The day keys are MO, TU, WE, TH, FR, SA and SU.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}POOL_TICKET in package $TMP.
|
|
- The class is public and final. It has a public constructor without parameters.
|
|
- The class has these public types:
|
|
ty_zone TYPE c LENGTH 2, ty_rate TYPE c LENGTH 1, ty_day TYPE c LENGTH 2,
|
|
ty_flag TYPE c LENGTH 1, ty_status TYPE c LENGTH 2,
|
|
ty_amount TYPE p LENGTH 8 DECIMALS 2.
|
|
- The class has the public constant structure c_status with the components
|
|
ok = 'OK', zone = 'ZN', rate = 'RT', day = 'DY'.
|
|
- The class has the public constant structure c_flag with the components
|
|
member = 'X', guest = ' '.
|
|
- The class has these public methods:
|
|
check_booking
|
|
IMPORTING iv_zone TYPE ty_zone
|
|
iv_rate TYPE ty_rate
|
|
iv_day TYPE ty_day
|
|
RETURNING VALUE(rv_status) TYPE ty_status.
|
|
ticket_price
|
|
IMPORTING iv_zone TYPE ty_zone
|
|
iv_rate TYPE ty_rate
|
|
iv_day TYPE ty_day
|
|
iv_member TYPE ty_flag
|
|
RETURNING VALUE(rv_price) TYPE ty_amount.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
1. An area code is known if it is IN, OU, SA or AL. Compare the codes exactly.
|
|
Do not convert the codes to upper case.
|
|
2. A rate code is known if it is A, C or S.
|
|
3. A day key is known if it is MO, TU, WE, TH, FR, SA or SU.
|
|
4. check_booking checks the area code, then the rate code, then the day key.
|
|
It returns the status of the first check that fails. If all three checks
|
|
pass, it returns OK.
|
|
5. ticket_price returns 0 if check_booking does not return OK.
|
|
6. Else the price is the base price of the area and the rate, plus the weekend
|
|
surcharge, minus the member discount.
|
|
7. The base price in euro:
|
|
IN: A 10.00, C 5.00, S 7.50
|
|
OU: A 7.50, C 3.75, S 5.00
|
|
SA: A 15.00, C 7.50, S 11.25
|
|
AL: A 20.00, C 10.00, S 15.00
|
|
8. The weekend surcharge is 2.50. It applies when the day key is SA or SU.
|
|
9. The member discount is 20 per cent. It applies when iv_member is X. Apply
|
|
the discount to the sum of the base price and the surcharge.
|
|
|
|
# 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 or create other objects.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|