Files
2026-10-05 22:08:59 +02:00

82 lines
3.0 KiB
Markdown

# 1. Goal
A ready-mix concrete plant supplies building sites. The plant office needs the
quantities of cement, sand, gravel and water for each order. The order desk, the
plant control system and the delivery note must use the same calculation. Create
one interface that holds this calculation.
# 2. Open questions
None.
# 3. Context
- One order has a concrete grade and a volume in cubic metres.
- The plant supplies the grades C20, C25, C30 and C35.
- Create the interface {{P}}IF_MIX_RECIPE in package $TMP.
- The interface holds the types, the constants and the methods of section 4.
- The interface contains the logic of section 5. A class that implements the
interface and does not redefine the methods must get the results of section 5.
# 4. Contract
Interface {{P}}IF_MIX_RECIPE in package $TMP.
Types:
- TY_GRADE TYPE c LENGTH 4
- TY_QTY TYPE p LENGTH 8 DECIMALS 2
- TY_STATUS TYPE c LENGTH 10
- TY_MIX: a structure with the components GRADE (TY_GRADE), CEMENT_KG, SAND_KG,
GRAVEL_KG and WATER_L (each TY_QTY).
Constant structure C_GRADE with the components C20, C25, C30 and C35. Each
component has the type TY_GRADE. The values are 'C20', 'C25', 'C30' and 'C35'.
Constant structure C_STATUS with the components OK, GRADE and VOLUME. Each
component has the type TY_STATUS. The values are 'OK', 'GRADE' and 'VOLUME'.
Method CHECK_ORDER:
IMPORTING iv_grade TYPE ty_grade
iv_volume TYPE ty_qty
RETURNING VALUE(rv_status) TYPE ty_status
Method MIX_FOR:
IMPORTING iv_grade TYPE ty_grade
iv_volume TYPE ty_qty
RETURNING VALUE(rs_mix) TYPE ty_mix
Do not add other public components to the interface.
# 5. Business rules
CHECK_ORDER returns the status of the first rule that fails.
1. Compare the grade without regard to case.
2. If the grade is not C20, C25, C30 or C35, return GRADE.
3. If the volume is below 0.50 or above 20.00, return VOLUME.
4. Otherwise return OK.
MIX_FOR returns the quantities of one order.
1. If CHECK_ORDER does not return OK, the component GRADE is empty and the four
quantities are 0.
2. The quantities for one cubic metre are:
grade cement sand gravel water
C20 280 720 1180 175
C25 320 700 1160 175
C30 360 680 1140 170
C35 400 660 1120 165
The unit of cement, sand and gravel is one kilogram. The unit of water is one
litre.
3. Multiply each quantity by the volume.
4. If the volume is below 2.00, add 10% to each quantity.
5. Round each quantity up to the next full kilogram. Round the water up to the
next full litre.
6. The component GRADE of the result is the grade of the order in upper case.
# 6. Constraints
- Release target: 7.58.
- Coding standards: Clean ABAP. Method length below 40 statements. No global
variables. No comment that restates the code.
- Out of scope: do not change any other object in package $TMP.
# 7. Acceptance
- The interface is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the interface.