Files

2.8 KiB

1. Goal

A car dealership accepts used cars as trade-ins. A sales program calls one valuation for each offered car before the dealership makes an offer to the customer. The valuation returns the trade-in value in whole euros and a reason code.

2. Open questions

None.

3. Context

  • The interface {{P}}IF_TRADE_IN exists in package $TMP. It is active.
  • The interface defines the whole contract of the valuation: the result structure, the input types, the three brand groups, the four condition grades, the reason codes and one method. Read the interface in the system.
  • The dealership uses the brand groups premium, volume and budget and the condition grades A, B, C and D.
  • All amounts are whole euros. All arithmetic is integer arithmetic.

4. Contract

  • Create the class {{P}}TRADE_IN_VALUER in package $TMP.
  • The class is public, final, and has a public constructor without parameters.
  • The class implements {{P}}IF_TRADE_IN.
  • Do not add other public methods.
  • Do not change {{P}}IF_TRADE_IN.

5. Business rules

Apply the rules in this sequence. Return the reason code of the first rule that fails. The interface defines one reason code for each rule below and one reason code for a successful valuation. Each code is named after the rule that it reports.

  1. The brand group must be one of the three brand groups that the interface defines. If not, return the reason code for the brand group.
  2. The condition grade must be one of the four grades that the interface defines. If not, return the reason code for the condition grade.
  3. The age in months must be between 0 and 600. If not, return the reason code for the age.
  4. The mileage in kilometres must be between 0 and 1000000. If not, return the reason code for the mileage.
  5. The base value is 30000 euros for the premium brand group, 20000 euros for the volume brand group and 12000 euros for the budget brand group.
  6. Deduct 1 percent of the base value for each month of age.
  7. Deduct 1 percent of the base value for each complete block of 10000 kilometres of mileage. Only complete blocks count. A mileage of 25000 kilometres contains two complete blocks and 5000 kilometres that do not count. A mileage of 9999 kilometres contains no complete block.
  8. Multiply the result by the grade factor: grade A 110 percent, grade B 100 percent, grade C 80 percent, grade D 60 percent.
  9. If the result is below 500, the value is 500.
  10. Return the value and the reason code for a successful valuation.

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_TRADE_IN.

7. Acceptance

  • The class is active and has no syntax error.
  • The hidden tests pass.
  • Write your own ABAP Unit tests for the class.