# 1. Goal A property management company checks a tenancy application before it offers a flat to an applicant. The office calls the check for each application. The office also needs the deposit that the applicant must pay. # 2. Open questions None. # 3. Context - The office works with one interface and one class that implements the interface. - The interface {{P}}IF_TENANCY_CHECK holds the types, the constants and the method signatures of the tenancy check. - The class {{P}}TENANCY_CHECKER holds the logic. - The method CHECK returns one reason code for each tenancy application. - The method DEPOSIT returns the deposit of a tenancy application. # 4. Contract Create the interface {{P}}IF_TENANCY_CHECK in package $TMP. The interface is public. It has these components and no other components. Types: - TY_REASON: type c, length 10. - TY_EMPLOYMENT: type c, length 1. - TY_AMOUNT: type p, length 8, 2 decimal places. Constants: - C_EMPLOYMENT: a constant structure with the components PERMANENT, FIXED and SELF. Each component has the type TY_EMPLOYMENT. The values are: PERMANENT = 'P', FIXED = 'F', SELF = 'S'. - C_REASON: a constant structure with the components OK, RENT, INCOME, PERSONS, CAPACITY, EMPLOYMENT and RATIO. Each component has the type TY_REASON. The values are: OK = 'OK', RENT = 'RENT', INCOME = 'INCOME', PERSONS = 'PERSONS', CAPACITY = 'CAPACITY', EMPLOYMENT = 'EMPLOYMENT', RATIO = 'RATIO'. Methods: - CHECK IMPORTING iv_rent TYPE ty_amount iv_income TYPE ty_amount iv_rooms TYPE i iv_persons TYPE i iv_employment TYPE ty_employment iv_pets TYPE abap_bool RETURNING VALUE(rv_reason) TYPE ty_reason. - DEPOSIT IMPORTING iv_rent TYPE ty_amount iv_pets TYPE abap_bool RETURNING VALUE(rv_deposit) TYPE ty_amount. Create the class {{P}}TENANCY_CHECKER in package $TMP. - The class is public, final, and has a public constructor without parameters. - The class implements {{P}}IF_TENANCY_CHECK. - Do not add other public methods. # 5. Business rules The method CHECK applies the rules in this sequence. It returns the reason of the first rule that fails. 1. If iv_rent is less than or equal to zero, return RENT. 2. If iv_income is less than or equal to zero, return INCOME. 3. If iv_persons is less than one, return PERSONS. 4. If iv_persons is greater than two times iv_rooms, return CAPACITY. 5. If iv_employment is not 'P', 'F' or 'S', return EMPLOYMENT. 6. The income factor is 3 for 'P', 4 for 'F' and 5 for 'S'. If iv_pets is true, add 1 to the income factor. If iv_income is less than iv_rent multiplied by the income factor, return RATIO. 7. Return OK. The method DEPOSIT applies the rules in this sequence. 1. If iv_rent is less than or equal to zero, return 0. 2. If iv_pets is true, return three times iv_rent. 3. Return two times iv_rent. # 6. Constraints - Release target: SAP_BASIS 816 (ABAP Platform 2025). - Coding standards: Clean ABAP. Method length below 40 statements. No global variables. No comment that restates the code. - Out of scope: do not create database tables, CDS views, reports or function modules. # 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.