CLASS zcl_elyses_enchantments_exampl DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.

    TYPES:
      ty_stack TYPE STANDARD TABLE OF i WITH EMPTY KEY .

    "! Get card at position
    METHODS get_item
      IMPORTING
        !stack        TYPE ty_stack
        !position     TYPE i
      RETURNING
        VALUE(result) TYPE i .
    "! Replace card at position
    METHODS set_item
      IMPORTING
        !stack        TYPE ty_stack
        !position     TYPE i
        !replacement  TYPE i
      RETURNING
        VALUE(result) TYPE ty_stack .
    "Add card to stack
    METHODS insert_item_at_top
      IMPORTING
        !stack        TYPE ty_stack
        !new_card     TYPE i
      RETURNING
        VALUE(result) TYPE ty_stack .
    "! Remove card at position
    METHODS remove_item
      IMPORTING
        !stack        TYPE ty_stack
        !position     TYPE i
      RETURNING
        VALUE(result) TYPE ty_stack .
    "! Remove top card (last row)
    METHODS remove_item_from_top
      IMPORTING
        !stack        TYPE ty_stack
      RETURNING
        VALUE(result) TYPE ty_stack .
    "! Add card to bottom of stack (first row)
    METHODS insert_item_at_bottom
      IMPORTING
        !stack        TYPE ty_stack
        !new_card     TYPE i
      RETURNING
        VALUE(result) TYPE ty_stack .
    "! Remove bottom card (delete first row)
    METHODS remove_item_from_bottom
      IMPORTING
        !stack        TYPE ty_stack
      RETURNING
        VALUE(result) TYPE ty_stack .
    "! Count cards
    METHODS get_size_of_stack
      IMPORTING
        !stack        TYPE ty_stack
      RETURNING
        VALUE(result) TYPE i .
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS zcl_elyses_enchantments_exampl IMPLEMENTATION.


  METHOD get_item.
    result = stack[ position ].
  ENDMETHOD.


  METHOD get_size_of_stack.
    result = lines( stack ).
  ENDMETHOD.


  METHOD insert_item_at_bottom.
    result = stack.
    INSERT new_card INTO result INDEX 1.
  ENDMETHOD.


  METHOD insert_item_at_top.
    result = stack.
    APPEND new_card TO result.
  ENDMETHOD.


  METHOD remove_item.
    result = stack.
    DELETE result INDEX position.
  ENDMETHOD.


  METHOD remove_item_from_bottom.
    result = stack.
    DELETE result INDEX 1.
  ENDMETHOD.


  METHOD remove_item_from_top.
    result = stack.
    DELETE result INDEX lines( stack ).
  ENDMETHOD.


  METHOD set_item.
    result = stack.
    MODIFY result INDEX position FROM replacement.
  ENDMETHOD.
ENDCLASS.
