SIMPLE PUZZLE GAME


Step 1:

Design a screen as show below with a push button ‘START’ in a module pool programming (SE38).



Step 2:

Write the below code in the PAI event of the screen you designed in the above step and Save and Activate.

PROGRAM  ZPUZZLE.

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module USER_COMMAND_9000 input.
data ok_code type sy-ucomm.
ok_code = sy-ucomm.
case ok_code.
  
when 'GAME'.
    
submit ZGAME and return.
    
endcase.
endmodule.                 " USER_COMMAND_9000  INPUT



Step 3 :

As we mentioned in the submit statement, Create a report program named ‘ZGAME’ using transaction SE38, add the below code in it, save and activate.

REPORT  ZGAME.
data answer(3type c.
data box(3) type c value 10.
data row type i.
data inc type i.
data flag type c.
do 5 times.

"For random icons generation
CALL FUNCTION 'QF05_RANDOM_INTEGER'
EXPORTING
  ran_int_max = 
110
  ran_int_min = 
10
IMPORTING
  ran_int = row.
enddo.
answer = row.
do 12 times.
  
do 7 times.
  flag = box 
mod 9.
  inc = box - 
9.
  
if flag = 0.
  
write : inc,answer as ICON NO-GAP.
  
else.
  
write : inc,box as ICON NO-GAP.
  
endif.
  box = box + 
1.
  
enddo.
  
write :/.
  
enddo.
at line-selection.
  
write : answer as icon, /, 'Is this right?'.



OUTPUT :

Now you can execute the program ‘ZPUZZLE’.










By Karthick.R, Kaavian Systems.

No comments:

Post a Comment