"! <p class="shorttext synchronized" lang="en">Flight Data Basic Class</p>
CLASS ZCL_OO_TUTORIAL_6_BASE DEFINITION
  PUBLIC
  abstract
  CREATE PROTECTED.

  PUBLIC SECTION.
    INTERFACES ZIF_OO_TUTORIAL.


    ALIASES CALCULATE_FLIGHT_PRICE
      FOR ZIF_OO_TUTORIAL~CALCULATE_FLIGHT_PRICE .
    ALIASES GET_FLIGHT_DETAILS
      FOR ZIF_OO_TUTORIAL~GET_FLIGHT_DETAILS .
    ALIASES COST
      FOR ZIF_OO_TUTORIAL~COST .

    CONSTANTS:
      "! <p class="shorttext synchronized" lang="en">Plane Type Enumerator</p>
      BEGIN OF PLANE_TYPE,
        B747 TYPE /DMO/PLANE_TYPE_ID VALUE `747`,
        A340 TYPE /DMO/PLANE_TYPE_ID VALUE `A340`,
      END OF PLANE_TYPE .

    "! <p class="shorttext synchronized" lang="en">CONSTRUCTOR</p>
    METHODS CONSTRUCTOR
      IMPORTING
        !FLIGHT TYPE /DMO/FLIGHT .

    "! <p class="shorttext synchronized" lang="en">Get Filght Object</p>
    CLASS-METHODS GET_FLIGHT_OBJECT
      IMPORTING
        !CARRIER_ID    TYPE /DMO/CARRIER_ID
        !CONNECTION_ID TYPE /DMO/CONNECTION_ID
        !FLIGHT_DATE   TYPE /DMO/FLIGHT_DATE
      RETURNING
        VALUE(FLIGHT)  TYPE REF TO ZCL_OO_TUTORIAL_6_BASE
      RAISING
        ZCX_OO_TUTORIAL.
  PROTECTED SECTION.
*"* protected components of class ZCL_OO_TUTORIAL_6_BASE
*"* do not include other source files here!!!

    "! <p class="shorttext synchronized" lang="en">Flight</p>
    DATA FLIGHT TYPE /DMO/FLIGHT .

  PRIVATE SECTION.
    "! <p class="shorttext synchronized" lang="en">Base Class Name</p>
    CONSTANTS CLASS_BASE_NAME TYPE STRING VALUE `ZCL_OO_TUTORIAL_6_`. "#EC NOTEXT
    "! <p class="shorttext synchronized" lang="en">Class Name Other</p>
    CONSTANTS CLASS_OTHER TYPE STRING VALUE `OTHER`.        "#EC NOTEXT
ENDCLASS.



CLASS ZCL_OO_TUTORIAL_6_BASE IMPLEMENTATION.


  METHOD CONSTRUCTOR.
    ME->FLIGHT = FLIGHT.
  ENDMETHOD.


  METHOD GET_FLIGHT_OBJECT.

    SELECT SINGLE * FROM /DMO/FLIGHT
    WHERE CARRIER_ID = @CARRIER_ID
      AND CONNECTION_ID = @CONNECTION_ID
      AND FLIGHT_DATE = @FLIGHT_DATE
     INTO @DATA(FLIGHT_TEMP).
    IF SY-SUBRC NE 0.
      RAISE EXCEPTION NEW ZCX_OO_TUTORIAL(
        TEXTID   = ZCX_OO_TUTORIAL=>FLIGHT_NOT_FOUND
        CARRID   = CARRIER_ID ).
    ENDIF.

    DATA CLASS_NAME TYPE STRING.
    IF FLIGHT_TEMP-PLANE_TYPE_ID CS ZCL_OO_TUTORIAL_6_BASE=>PLANE_TYPE-B747.
      CLASS_NAME = ZCL_OO_TUTORIAL_6_BASE=>CLASS_BASE_NAME &&
                   ZCL_OO_TUTORIAL_6_BASE=>PLANE_TYPE-B747.

    ELSEIF FLIGHT_TEMP-PLANE_TYPE_ID CS ZCL_OO_TUTORIAL_6_BASE=>PLANE_TYPE-A340.
      CLASS_NAME = ZCL_OO_TUTORIAL_6_BASE=>CLASS_BASE_NAME &&
                   ZCL_OO_TUTORIAL_6_BASE=>PLANE_TYPE-A340.
    ELSE.
      CLASS_NAME = ZCL_OO_TUTORIAL_6_BASE=>CLASS_BASE_NAME &&
                   ZCL_OO_TUTORIAL_6_BASE=>CLASS_OTHER.
    ENDIF.

    CREATE OBJECT FLIGHT TYPE (CLASS_NAME)
      EXPORTING
        FLIGHT = FLIGHT_TEMP.

  ENDMETHOD.


  METHOD ZIF_OO_TUTORIAL~CALCULATE_FLIGHT_PRICE.

    PRICE-PRICE = ME->FLIGHT-PRICE + 100.
    PRICE-CURRENCY = ME->FLIGHT-CURRENCY_CODE.

  ENDMETHOD.


  METHOD ZIF_OO_TUTORIAL~GET_FLIGHT_DETAILS.
    FLIGHT = ME->FLIGHT.
  ENDMETHOD.
ENDCLASS.
