abap 数字移动小游戏

【转自 http://blog.csdn.net/forever_crazy/article/details/6542507】

report ......

selection-screen pushbutton 2(10)  pb11 user-command pb11.
selection-screen pushbutton 12(10) pb12 user-command pb12.
selection-screen pushbutton 22(10) pb13 user-command pb13.

selection-screen skip.
selection-screen pushbutton 2(10)  pb21 user-command pb21.
selection-screen pushbutton 12(10) pb22 user-command pb22.
selection-screen pushbutton 22(10) pb23 user-command pb23.

selection-screen skip.
selection-screen pushbutton 2(10)  pb31 user-command pb31.
selection-screen pushbutton 12(10) pb32 user-command pb32.
selection-screen pushbutton 22(10) pb33 user-command pb33.

selection-screen skip.
selection-screen pushbutton 12(10) pbrt user-command pbrt.

INITIALIZATION.
  "设定画面的初始值
  pb11 = ‘2‘. 
  pb12 = ‘1‘.
  pb13 = ‘4‘. 
  pb21 = ‘7‘. 
  pb22 = ‘3‘.
  pb23 = ‘6‘. 
  pb31 = ‘8‘. 
  pb32 = ‘ ‘.
  pb33 = ‘5‘.

at selection-screen.
  case sy-ucomm.
    when ‘pb11‘.
      perform exec_pb11.  
    when ‘pb12‘.
      perform exec_pb12.
    when ‘pb13‘.
      perform exec_pb13.
    when ‘pb21‘.
      perform exec_pb21.
    when ‘pb22‘.
      perform exec_pb22.
    when ‘pb23‘.
      perform exec_pb23.
    when ‘pb31‘.
      perform exec_pb31.
    when ‘pb32‘.
      perform exec_pb32.
    when ‘pb33‘.
      perform exec_pb33.

when ‘pbrt‘
      perform exec_right_result.
    when 
  endcase.

form exec_pb11 .
  check pb11 is not initial.
  perform move_data changing pb11
                             pb12.
  perform move_data changing pb11
                             pb21.
endform.

form exec_pb12 .
  check pb12 is not initial.
  perform move_data changing pb12
                             pb11.
  perform move_data changing pb12
                             pb13.
  perform move_data changing pb12
                             pb22.
endform.

form exec_pb13 .
  check pb13 is not initial.
  perform move_data changing pb13
                             pb12.
  perform move_data changing pb13
                             pb23.
endform.

form exec_pb21 .
  check pb21 is not initial.
  perform move_data changing pb21
                             pb11.
  perform move_data changing pb21
                             pb22.
  perform move_data changing pb21
                             pb31.
endform.

form exec_pb22 .
  check pb22 is not initial.
  perform move_data changing pb22
                             pb12.
  perform move_data changing pb22
                             pb21.
  perform move_data changing pb22
                             pb23.
  perform move_data changing pb22
                             pb32.
endform.

form exec_pb23 .
  check pb23 is not initial.
  perform move_data changing pb23
                             pb13.
  perform move_data changing pb23
                             pb22.
  perform move_data changing pb23
                             pb33.
endform.

form exec_pb31 .
  check pb31 is not initial.
  perform move_data changing pb31
                             pb21.
  perform move_data changing pb31
                             pb32.
endform.

form exec_pb32 .
  check pb32 is not initial.
  perform move_data changing pb32
                             pb22.
  perform move_data changing pb32
                             pb31.
  perform move_data changing pb32
                             pb33.
endform.

form exec_pb33 .
  check pb32 is not initial.
  perform move_data changing pb33
                             pb23.
  perform move_data changing pb33
                             pb32.
endform.

form move_data changing p_pb1 type any
                        p_pb2 type any.
 "实现把点击的那按钮 移动到临近的空白按钮上 
  check p_pb1 is not initial
    and p_pb2 is initial.
  p_pb2 = p_pb1.
  clear pb1.
  
  perform check_right_result.

endform.

form check_right_result.
  if pb11 = ‘1‘
 and pb12 = ‘2‘
 and pb13 = ‘3‘
 and pb21 = ‘4‘
 and pb22 = ‘5‘
 and pb23 = ‘6‘
 and pb31 = ‘7‘
 and pb32 = ‘8‘
 and pb33 = ‘ ‘
    message ‘Very good !  boys‘. 
    leave screen.
  endif.
endform.

form exec_right_result.
 "正确结果为:
  pb11 = ‘1‘.
  pb12 = ‘2‘.
  pb13 = ‘3‘.
  pb21 = ‘4‘.
  pb22 = ‘5‘.
  pb23 = ‘6‘.
  pb31 = ‘7‘.
  pb32 = ‘8‘.
  pb33 = ‘ ‘.
endform.

时间: 2024-07-31 09:00:13

abap 数字移动小游戏的相关文章

java编程的一个猜数字有趣小游戏

import javax.swing.Icon; import javax.swing.JOptionPane; public class ai { /** * @param args */ public static void main(String[] args) { Icon icon = null; boolean bl = false; int put = 0; int c = (int) (((Math.random())*100)+1); //获取一个1-100的随机数 Syste

C语言实现,猜数字智力小游戏

#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <time.h> int main() {  printf("   欢迎使用猜数字游戏! \n");  printf("\n");  printf("************************\n");  printf("\n"

C语言编写猜数字的小游戏

#include<stdio.h> #include<stdlib.h> #include<time.h> int main() { int num; srand((unsigned)time(NULL)); int ret=rand()%100+1; while(1) { printf("请输入一个数字>>\n"); scanf("%d",&num); if(num>ret) printf("

【python笔记 三 】python脚本实战---数字密码小游戏

描述:A输入一个数值,输入时该数值已隐藏无法看到,让B猜该数字为多少,数值过小或过大都会提示,并会在最后猜对时统计出共猜了几次. 脚本内容: #!/usr/bin/env python #FileName:while1.py import getpass    #调用模块 a = int(getpass.getpass('Enter A Number a:'))    #模块赋值 running = True i = 0 while running: b = int(raw_input('Ent

python小游戏之一--------猜数字

看了一下python的入门书,拿个小游戏来练练手,其实就几行代码,也只有新手和脸皮厚的吊丝才好意思拿出来献丑 就好像张X忠一样,来,上海带,天朝海军天下无敌了 这里主要是一个random函数和 while 循环语句的使用,没了 #-*- encoding: utf-8 -*- ''' Created on 2014年5月8日 @author: Administrator ''' import random keys = random.randint(1,100)    #这个函数的作用是给一个随

Python基础入门-实现猜数字小游戏

今天呢,我们来通过前面学过的一些知识点来完成一个猜数字大小的游戏程序设计.那么呢,一般人写代码直接上来就干,没有分析,这样的做法是没有产出的,除非你是大牛,今天呢,我会把我学习编程的思路分享给大家,我的思路可能不是最好的,但是一定可以给你一点点的启发,来,让我们看一下这个写这个小程序该怎么去分析呢? 需求分析:用python实现一个猜数字的小游戏(场景可以自拟)这里我给出的需求是,我们还是先看一下流程图吧! 程序分析流程图: 分析思路: 1.如果设置默认值也就是结果数字,那么请输出"I"

js、jQuery实现2048小游戏

一.游戏简介:  2048是一款休闲益智类的数字叠加小游戏 二. 游戏玩法: 在4*4的16宫格中,您可以选择上.下.左.右四个方向进行操作,数字会按方向移动,相邻的两个数字相同就会合并,组成更大的数字,每次移动或合并后会增加一个数字. 当16宫格中没有空格子,且四个方向都无法操作时,游戏结束. 三. 游戏目的: 目的是合并出2048这个数字,获得更高的分数. 四. 游戏截图:  五.先来玩一下: 开始游戏 查看源码 六.游戏实现原理: 使用js.jQuery实现了PC版及手机版,实现原理是一样

js选择颜色小游戏(随机生成不含重复数字的数组,通过数组中的数控制定义好的数组)

<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>js网页版小游戏</title> <style media="screen"> .wrap { width: 577px; outline: 1px solid hotpink; margin: 100px auto; box-shadow: 0 0 5px; } .

简单的猜数字小游戏

/** 简单的猜数字小游戏 要求如下: 用户输入想猜测数字的范围,输入1000则是0~1000之内的数字,程序就会内置一个 1 到 1000 之间的数字作为猜测的结果,由用户猜测此数字,用户每猜测一次,由系统提示猜测结果:大了.小了或者猜对了:直到用户猜对结果,则提示游戏结束.用户可以提前退出游戏,即,游戏过程中,如果用户录入数字0则游戏终止.加入新功能: 记次猜测次数功能,提示游戏开始时间,计猜测总用时功能,提示游戏结束时间 思路:1.用户输入电脑生成的数值取值范围,接收并判断是否是合理数值?