May 24th, 2007

light in the tunnel

(мрачно) Object COBOL бля

REPORT demo_class_counter .

CLASS counter DEFINITION.
PUBLIC SECTION.
METHODS: set IMPORTING value(set_value) TYPE i,
increment,
get EXPORTING value(get_value) TYPE i.
PRIVATE SECTION.
DATA count TYPE i.
ENDCLASS.

CLASS counter IMPLEMENTATION.
METHOD set.
count = set_value.
ENDMETHOD.
METHOD increment.
ADD 1 TO count.
ENDMETHOD.
METHOD get.
get_value = count.
ENDMETHOD.
ENDCLASS.

DATA number TYPE i VALUE 5.
DATA cnt TYPE REF TO counter.

START-OF-SELECTION.

CREATE OBJECT cnt.

CALL METHOD cnt->set EXPORTING set_value = number.

DO 3 TIMES.
CALL METHOD cnt->increment.
ENDDO.

CALL METHOD cnt->get IMPORTING get_value = number.

WRITE number.