*&---------------------------------------------------------------------* *& Report Y_JAMES_OO_DAY3 *& *&---------------------------------------------------------------------* *&Use a example to show what the hell OO!!!!! *&---------------------------------------------------------------------* REPORT Y_JAMES_OO_DAY3. CLASS Emp DEFINITION. PUBLIC SECTION. DATA: Empno TYPE n, Ename TYPE char10, Enums TYPE i, Eprice TYPE i. METHODS: Calculatepay RETURNING VALUE(ipay) TYPE i, Displaypay IMPORTING VALUE(ipay) TYPE i. ENDCLASS. CLASS Emp IMPLEMENTATION . METHOD Calculatepay. ipay = Enums * Eprice. ENDMETHOD. METHOD Displaypay. WRITE: / 'The pay for employee', Empno,Ename, 'is', ipay,/. ENDMETHOD. ENDCLASS. CLASS SpecialWorker DEFINITION INHERITING FROM Emp. PUBLIC SECTION. EVENTS: LazyEmployee. DATA: Enums_extra TYPE i. METHODS: Calculatepay REDEFINITION. ENDCLASS. CLASS SpecialWorker IMPLEMENTATION. METHOD Calculatepay. ipay = ( Enums * Eprice ) + ( Enums_extra * Eprice * 2 ) . IF Enums <= 100. WRITE: ename. RAISE EVENT LazyEmployee. ENDIF. ENDMETHOD. ENDCLASS. *CLASS FireWorker DEFINITION. CLASS FireWorker DEFINITION. PUBLIC SECTION. METHODS YouAreFired FOR EVENT LazyEmployee of Specialworker. ENDCLASS. CLASS FireWorker IMPLEMENTATION. METHOD YouAreFired. WRITE: / 'You are so lazy, because of produced less than 100 units,so you are be fired'. ENDMETHOD. ENDCLASS. DATA:MyPay TYPE i. START-OF-SELECTION. *----------------------------------------------------------------------- * Using the Employee named James to show you how to write *----------------------------------------------------------------------- DATA: Go_James TYPE REF TO Emp, Go_Scott TYPE REF TO specialworker, Go_Junji TYPE REF TO specialworker, Fire_Jun TYPE REF TO fireworker. CREATE OBJECT Go_james. go_james->empno = '111' . go_james->ename = 'James' . go_james->enums = '500' . go_james->eprice = '3' . mypay = go_james->calculatepay( ) . CALL METHOD go_james->displaypay( mypay ) . *CLEAR mypay. CREATE OBJECT go_scott. go_scott->empno = '222' . go_scott->ename = 'Scott' . go_scott->enums = '500' . go_scott->eprice = '3' . go_scott->enums_extra = '50' . mypay = go_scott->calculatepay( ) . CALL METHOD go_scott->displaypay( mypay ) . *CLEAR mypay. CREATE OBJECT: go_junji, fire_jun. SET HANDLER fire_jun->youarefired FOR go_junji. go_junji->empno = '333' . go_junji->ename = 'Jubjie' . go_junji->enums = '80' . go_junji->eprice = '3' . go_junji->enums_extra = '0' . *CLEAR mypay. mypay = go_junji->calculatepay( ) . CALL METHOD go_junji->displaypay( mypay ) .