CLASS {{p}}cine_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. CONSTANTS: c_evening TYPE t VALUE '200000', c_matinee TYPE t VALUE '160000', c_boundary TYPE t VALUE '170000', c_morning TYPE t VALUE '100000'. METHODS call_fee IMPORTING iv_show TYPE string iv_seats TYPE i iv_time TYPE t iv_cust TYPE string EXPORTING ev_total TYPE decfloat34 ev_disc TYPE decfloat34 ev_subrc TYPE sysubrc. METHODS base_price_2d FOR TESTING. METHODS base_prices_3d_imax FOR TESTING. METHODS invalid_seats FOR TESTING. METHODS invalid_show_type FOR TESTING. METHODS invalid_cust_type FOR TESTING. METHODS matinee_discount FOR TESTING. METHODS matinee_boundary FOR TESTING. METHODS child_skips_matinee FOR TESTING. METHODS group_threshold FOR TESTING. METHODS discount_cap FOR TESTING. METHODS rounding_half_up FOR TESTING. ENDCLASS. CLASS {{p}}cine_hidden IMPLEMENTATION. METHOD call_fee. ev_total = 0. ev_disc = 0. CALL FUNCTION '{{P}}CINE_FEE_OLD' EXPORTING iv_show_type = iv_show iv_seats = iv_seats iv_show_time = iv_time iv_cust_type = iv_cust IMPORTING ev_total = ev_total ev_discount = ev_disc EXCEPTIONS invalid_input = 1 OTHERS = 2. ev_subrc = sy-subrc. ENDMETHOD. METHOD base_price_2d. call_fee( EXPORTING iv_show = `2D` iv_seats = 1 iv_time = c_evening iv_cust = `ADULT` IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ev_subrc = DATA(lv_rc) ). cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '9.50' ) act = lv_total ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_disc ). ENDMETHOD. METHOD base_prices_3d_imax. call_fee( EXPORTING iv_show = `3D` iv_seats = 1 iv_time = c_evening iv_cust = `ADULT` IMPORTING ev_total = DATA(lv_total) ev_subrc = DATA(lv_rc) ). cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '13.00' ) act = lv_total ). call_fee( EXPORTING iv_show = `IMAX` iv_seats = 1 iv_time = c_evening iv_cust = `ADULT` IMPORTING ev_total = DATA(lv_total2) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '16.50' ) act = lv_total2 ). ENDMETHOD. METHOD invalid_seats. call_fee( EXPORTING iv_show = `2D` iv_seats = 0 iv_time = c_evening iv_cust = `ADULT` IMPORTING ev_subrc = DATA(lv_rc) ). cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ). ENDMETHOD. METHOD invalid_show_type. call_fee( EXPORTING iv_show = `XX` iv_seats = 1 iv_time = c_evening iv_cust = `ADULT` IMPORTING ev_subrc = DATA(lv_rc) ). cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ). ENDMETHOD. METHOD invalid_cust_type. call_fee( EXPORTING iv_show = `2D` iv_seats = 1 iv_time = c_evening iv_cust = `VIP` IMPORTING ev_subrc = DATA(lv_rc) ). cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ). ENDMETHOD. METHOD matinee_discount. call_fee( EXPORTING iv_show = `2D` iv_seats = 1 iv_time = c_matinee iv_cust = `ADULT` IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '7.25' ) act = lv_total ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 25 ) act = lv_disc ). ENDMETHOD. METHOD matinee_boundary. call_fee( EXPORTING iv_show = `2D` iv_seats = 1 iv_time = c_boundary iv_cust = `ADULT` IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '9.50' ) act = lv_total ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_disc ). ENDMETHOD. METHOD child_skips_matinee. call_fee( EXPORTING iv_show = `2D` iv_seats = 1 iv_time = c_morning iv_cust = `CHILD` IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '5.90' ) act = lv_total ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 40 ) act = lv_disc ). ENDMETHOD. METHOD group_threshold. call_fee( EXPORTING iv_show = `2D` iv_seats = 7 iv_time = c_evening iv_cust = `ADULT` IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '66.50' ) act = lv_total ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_disc ). call_fee( EXPORTING iv_show = `2D` iv_seats = 8 iv_time = c_evening iv_cust = `ADULT` IMPORTING ev_total = DATA(lv_total2) ev_disc = DATA(lv_disc2) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '68.80' ) act = lv_total2 ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 10 ) act = lv_disc2 ). ENDMETHOD. METHOD discount_cap. call_fee( EXPORTING iv_show = `2D` iv_seats = 8 iv_time = c_morning iv_cust = `SENIOR` IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '32.80' ) act = lv_total ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 60 ) act = lv_disc ). ENDMETHOD. METHOD rounding_half_up. call_fee( EXPORTING iv_show = `3D` iv_seats = 3 iv_time = c_matinee iv_cust = `ADULT` IMPORTING ev_total = DATA(lv_total) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '29.63' ) act = lv_total ). ENDMETHOD. ENDCLASS.