63 lines
2.4 KiB
Markdown
63 lines
2.4 KiB
Markdown
# 1. Goal
|
|
A cinema multiplex prices ticket orders. The checkout program calls one class
|
|
for each order. The class calculates the total price of the order and returns a
|
|
reason code.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The interface {{P}}IF_CINEMA_PRICE exists in package $TMP. It is active.
|
|
- The interface contains the exact signature of the calculation, the result
|
|
structure and the reason codes. Read the interface before you start.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}CINEMA_PRICER in package $TMP.
|
|
- The class is public and final. It has a public constructor without parameters.
|
|
- The class implements {{P}}IF_CINEMA_PRICE.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
The caller gives five values: the screen category, the visitor category, the
|
|
number of tickets, the hour when the show starts, and the loyalty card flag.
|
|
The calculation returns the total price and a reason code.
|
|
|
|
Screen categories and the base price of one ticket:
|
|
- S (standard): 9.50
|
|
- T (three-dimensional): 12.00
|
|
- L (large format): 15.00
|
|
|
|
Visitor categories and the discount on the base price:
|
|
- A (adult): 0 percent
|
|
- C (child): 30 percent
|
|
- S (senior): 40 percent
|
|
|
|
Check the input in this sequence. Stop at the first invalid value. Return a
|
|
price of zero and the reason of this value.
|
|
1. The screen category must be S, T or L. Else return the reason SCREEN.
|
|
2. The visitor category must be A, C or S. Else return the reason VISITOR.
|
|
3. The number of tickets must be 1 to 20. Else return the reason QUANTITY.
|
|
4. The hour must be 0 to 23. Else return the reason HOUR.
|
|
|
|
Calculate the price in this sequence:
|
|
5. Take the base price of the screen category.
|
|
6. Reduce the price of one ticket by the visitor discount.
|
|
7. If the hour is 20 or later, add a late-show surcharge of 1.50 to the price
|
|
of one ticket.
|
|
8. Multiply the price of one ticket by the number of tickets.
|
|
9. If the number of tickets is 6 or more, reduce the total by 10 percent.
|
|
10. If the loyalty card flag is true, reduce the total by 5 percent.
|
|
11. Round the total to two decimal places.
|
|
12. Return the total and the reason OK.
|
|
|
|
# 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_CINEMA_PRICE.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|