zoukankan      html  css  js  c++  java
  • ABAP------>OO 拔草

    *&---------------------------------------------------------------------*
    *& 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 ) .
  • 相关阅读:
    vim 常用指令总结
    冥想、反思
    FM(Factorization Machines)模型详解
    机器学习性能指标(ROC、AUC、召回率)
    数据库常用操作(mysql)
    shell命令总结
    Window Function--the function of window function
    Python用Pillow(PIL)进行简单的图像操作
    Pyecharts : plot Graph, Line, Liquid, Parallel
    机器学习方法--分类、回归、聚类
  • 原文地址:https://www.cnblogs.com/HARU/p/7998900.html
Copyright © 2011-2022 走看看