55 lines
2.4 KiB
Markdown
55 lines
2.4 KiB
Markdown
# 1. Goal
|
|
Calculate the hire fee of a mobile crane job. A quotation program calls the
|
|
calculation before it sends a quote to the customer. The program needs the fee
|
|
and one reason code for each request.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- Interface {{P}}IF_CRANE_HIRE exists in package $TMP. It is active.
|
|
- Read the interface. It contains the types, the reason codes and the signature
|
|
of the calculation method. Use the names of the interface.
|
|
- The method receives the working radius, the load, the ground type and a flag
|
|
for a road permit. It returns a reason code and a fee.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}CRANE_HIRE_CALC in package $TMP.
|
|
- The class is public and final. It has a public constructor without parameters.
|
|
- The class implements {{P}}IF_CRANE_HIRE.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
Apply the rules in this sequence.
|
|
1. If the radius is less than 5 or more than 60, return the radius reason and a
|
|
fee of 0.
|
|
2. If the load is less than 500, return the load reason and a fee of 0.
|
|
3. The crane has a load chart. The maximum load depends on the radius:
|
|
radius up to 10 m: 12000 kg, up to 20 m: 8000 kg, up to 30 m: 5000 kg,
|
|
up to 45 m: 3000 kg, up to 60 m: 1500 kg.
|
|
If the load is more than the maximum load for the radius, return the capacity
|
|
reason and a fee of 0.
|
|
4. Remove the leading and the trailing spaces from the ground type. Convert it
|
|
to upper case. The ground type must be ROAD, GRAVEL or SOIL. If not, return
|
|
the ground reason and a fee of 0.
|
|
5. Calculate the base fee: the radius in metres multiplied by 15, plus the load
|
|
in kilograms divided by 100 and rounded down, multiplied by 5.
|
|
6. Multiply the base fee by the ground factor and divide the result by 100. The
|
|
ground factors are: ROAD 100, GRAVEL 115, SOIL 135.
|
|
7. If the road permit is required, add 250 to the fee.
|
|
8. If the fee is less than 300, set the fee to 300.
|
|
9. Return the OK reason and the fee.
|
|
Round each multiplication by a ground factor to the nearest whole euro. Round
|
|
halves up. The fee is a whole number of euros.
|
|
|
|
# 6. Constraints
|
|
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
|
|
- 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_CRANE_HIRE.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|