Files

94 lines
3.2 KiB
Markdown

# 1. Goal
A baggage drop-off counter at an airport checks a bag before it accepts the bag.
The counter program calls the check. If the check rejects the bag, the program
shows the reason to the agent. The reason is a class-based exception.
# 2. Open questions
None.
# 3. Context
- All objects are in package $TMP.
- The check needs only the parameters of the method. No database table and no
helper object is necessary.
- The classes of the contract do not exist yet.
# 4. Contract
## 4.1 Class {{P}}BAG_DROP
- The class is public and final. It has a public constructor without parameters.
- The class has these public types:
- TY_TAG TYPE c LENGTH 10
- TY_WEIGHT TYPE p LENGTH 5 DECIMALS 2
- TY_SIZE TYPE i
- TY_COUNT TYPE i
- TY_MINUTES TYPE i
- The class has exactly one public method:
ACCEPT_BAG
IMPORTING
iv_tag TYPE ty_tag
iv_weight TYPE ty_weight
iv_length TYPE ty_size
iv_width TYPE ty_size
iv_height TYPE ty_size
iv_bags_checked TYPE ty_count
iv_min_to_dep TYPE ty_minutes
RAISING
{{P}}CX_BAG_TAG
{{P}}CX_BAG_WEIGHT
{{P}}CX_BAG_SIZE
{{P}}CX_BAG_LIMIT
{{P}}CX_BAG_LATE
- Do not add other public methods.
## 4.2 Exception classes
Create the classes {{P}}CX_BAG_TAG, {{P}}CX_BAG_WEIGHT, {{P}}CX_BAG_SIZE,
{{P}}CX_BAG_LIMIT and {{P}}CX_BAG_LATE.
- Each class is public and final. Each class inherits from CX_STATIC_CHECK.
- Each class has a public constructor without parameters.
- Each class has the public read-only attribute MV_TEXT of type string. MV_TEXT
contains the message text of the class. The business rules give the message
texts.
# 5. Business rules
The method ACCEPT_BAG checks the bag. It applies the rules in this sequence and
raises the exception of the first rule that fails. It raises no exception if all
rules pass.
1. Every character of the tag is a digit 0 to 9 or an upper-case letter A to Z.
If not, raise {{P}}CX_BAG_TAG. The message text is "Invalid bag tag".
2. The weight in kg is not greater than 23. If it is greater, raise
{{P}}CX_BAG_WEIGHT. The message text is "Bag is too heavy".
3. The sum of the length, the width and the height in cm is not greater than 158.
If it is greater, raise {{P}}CX_BAG_SIZE. The message text is "Bag is too
large".
4. The number of bags that the passenger already checked in is less than 2. If
it is 2 or more, raise {{P}}CX_BAG_LIMIT. The message text is "Bag limit
reached".
5. The minutes until the departure are 40 or more. If they are less, raise
{{P}}CX_BAG_LATE. The message text is "Check-in closed".
# 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 the standard classes CX_ROOT and CX_STATIC_CHECK.
# 7. Acceptance
- All objects are active and have no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class {{P}}BAG_DROP. Your tests cover
every business rule, the exact limits, and the sequence of the rules. Your
tests handle every exception that the method can raise.
- The ATC check of your objects has no finding of priority 1 or 2.