Created
June 24, 2012 12:51
-
-
Save furlan/2983147 to your computer and use it in GitHub Desktop.
ZABAP101_RECURSION - with error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*&---------------------------------------------------------------------* | |
*& Report ZABAP101_RECURSION | |
*& | |
*&---------------------------------------------------------------------* | |
*& | |
*& | |
*&---------------------------------------------------------------------* | |
REPORT zabap101_recursion. | |
*----------------------------------------------------------------------* | |
* CLASS lcl_math DEFINITION | |
*----------------------------------------------------------------------* | |
* | |
*----------------------------------------------------------------------* | |
CLASS lcl_math DEFINITION. | |
PUBLIC SECTION. | |
METHODS execute_exponentiation | |
IMPORTING | |
base TYPE i | |
expoent TYPE i | |
RETURNING value(re_power) TYPE i. | |
PRIVATE SECTION. | |
DATA: interaction TYPE i. | |
ENDCLASS. "lcl_math DEFINITION | |
*----------------------------------------------------------------------* | |
* CLASS lcl_math IMPLEMENTATION | |
*----------------------------------------------------------------------* | |
* | |
*----------------------------------------------------------------------* | |
CLASS lcl_math IMPLEMENTATION. | |
METHOD execute_exponentiation. | |
ADD 1 TO interaction. | |
IF interaction <= expoent. | |
re_power = re_power * me->execute_exponentiation( base = base | |
expoent = expoent ). | |
ELSE. | |
CLEAR interaction. | |
ENDIF. | |
ENDMETHOD. "execute_exponentiation | |
ENDCLASS. "lcl_math IMPLEMENTATION | |
DATA: r_exp TYPE REF TO lcl_math, | |
v_power TYPE i. | |
PARAMETERS: p_base TYPE i DEFAULT 2, | |
p_exp TYPE i DEFAULT 3. | |
INITIALIZATION. | |
CREATE OBJECT r_exp. | |
START-OF-SELECTION. | |
v_power = r_exp->execute_exponentiation( base = p_base | |
expoent = p_exp ). | |
WRITE: / 'Power: ', v_power. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment