3.1 KiB
3.1 KiB
1. Goal
A chimney sweep company serves private houses and small businesses. Before the dispatcher schedules a sweep, the dispatch program checks each sweep order and calculates the sweep fee. The program needs one reason code for each order.
2. Open questions
None.
3. Context
- Package $TMP.
- The dispatch program uses the interface {{P}}IF_SWEEP_CHECK and the class {{P}}CHIMNEY_CHECKER.
- One flue is one chimney channel. A sweep order covers one or more flues.
- iv_last_sweep is the year of the last sweep of the order.
- iv_year is the current year.
- iv_blocked is true when the customer blocked the access to the building.
4. Contract
- Create the interface {{P}}IF_SWEEP_CHECK in package $TMP. The interface has
these public components:
- TYPES ty_reason TYPE c LENGTH 10.
- TYPES ty_flue_kind TYPE c LENGTH 4.
- TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
- The constant structure c_reason with the components ok, no_flues, too_many, bad_kind, blocked, old_sweep. Each component has the type ty_reason and these values: 'OK', 'NO_FLUES', 'TOO_MANY', 'BAD_KIND', 'BLOCKED', 'OLD_SWEEP'.
- The constant structure c_kind with the components open, closed, indust. Each component has the type ty_flue_kind and these values: 'OPEN', 'CLOS', 'INDU'.
- The constant c_max_flues with the type i and the value 12.
- The method check_order with the parameters IMPORTING iv_flues TYPE i iv_kind TYPE ty_flue_kind iv_last_sweep TYPE i iv_year TYPE i iv_blocked TYPE abap_bool RETURNING VALUE(rv_reason) TYPE ty_reason.
- The method fee with the parameters IMPORTING iv_flues TYPE i iv_kind TYPE ty_flue_kind RETURNING VALUE(rv_fee) TYPE ty_amount.
- Create the class {{P}}CHIMNEY_CHECKER in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class implements {{P}}IF_SWEEP_CHECK.
- Do not add other public methods to the class.
5. Business rules
5.1 Check of a sweep order
Apply the rules in this sequence. Return the reason of the first rule that fails.
- If iv_flues is less than 1, return NO_FLUES.
- If iv_flues is greater than c_max_flues, return TOO_MANY.
- If iv_kind is not OPEN, CLOS or INDU, return BAD_KIND.
- If iv_blocked is true, return BLOCKED.
- If iv_year minus iv_last_sweep is greater than 2, return OLD_SWEEP.
- Else return OK.
5.2 Fee of a sweep order
- The fee of one flue depends on the flue kind: OPEN 60.00, CLOS 45.00, INDU 120.00. Any other flue kind has a fee of 0.00.
- The total is the fee of one flue multiplied by iv_flues.
- If iv_flues is 5 or more, reduce the total by 10 percent.
- Round the result to 2 decimals.
- If iv_flues is less than 1, the fee is 0.00.
6. Constraints
- Release target: SAP_BASIS 816.
- Coding standards: Clean ABAP. Method length below 40 statements. No global variables. No comment that restates the code.
- Out of scope: no other objects in package $TMP.
7. Acceptance
- The interface and the class are active and have no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.