2.6 KiB
2.6 KiB
1. Goal
A community garden association rents garden plots to its tenants and charges an annual rent for each plot. The billing program of the association calls one calculation for each plot. The program needs the rent and one reason code for each plot.
2. Open questions
None.
3. Context
- The class {{P}}GARDEN_RENT does not exist. Create it in package $TMP.
- The billing program calls the class for each plot. It passes the plot type, the area of the plot in square metres, a flag that tells if the plot has a water connection, and a flag that tells if the tenant is a member of the association.
4. Contract
- Create the class {{P}}GARDEN_RENT in package $TMP.
- The class is public and final. It has a public constructor without parameters.
- Do not add other public methods.
- Define these public types:
- TY_PLOT_TYPE: type c, length 4.
- TY_REASON: type c, length 10.
- TY_AMOUNT: type p, length 8, 2 decimals.
- TY_RESULT: structure with the components REASON (type TY_REASON) and RENT (type TY_AMOUNT).
- Define the public constant structure C_REASON with the components OK, PLOT and AREA. The values are 'OK', 'PLOT' and 'AREA'.
- The class has the public method CALCULATE with these parameters:
- importing IV_PLOT_TYPE, type TY_PLOT_TYPE.
- importing IV_AREA, type i.
- importing IV_WATER, type abap_bool.
- importing IV_MEMBER, type abap_bool.
- returning RS_RESULT, type TY_RESULT.
5. Business rules
Apply the rules in this sequence. The first rule that fails decides the result.
- Convert the plot type to upper case.
- The plot type must be STD, PREM or BED. If not, return the reason PLOT and the rent 0.00.
- The area must be between 10 and 500 square metres. Both limits are included. If not, return the reason AREA and the rent 0.00.
- The rent per square metre depends on the plot type: STD = 0.35, PREM = 0.60, BED = 0.90.
- The rent is the area multiplied by the rent per square metre.
- If the plot has a water connection, add 12.00.
- If the tenant is a member of the association, subtract 15 percent of that amount.
- Round the rent to two decimals. Round half up: 22.695 becomes 22.70.
- The rent must be at least 10.00. If it is less, use 10.00.
- Return the reason OK and the rent.
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 create other objects and do not use a database table.
7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.