| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 470 人关注过本帖
标题:c#中的移动应用开发 猜字母游戏
只看楼主 加入收藏
qq1159924411
Rank: 1
来 自:甘肃天水
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-2-13
收藏
 问题点数:0 回复次数:0 
c#中的移动应用开发 猜字母游戏
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DeviceApplication1
{
    public partial class Form1 : Form
    {
        public int mj;
        public int nj;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            label3.Text = " ";
            label4.Text = " ";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label3.Text = "";
            label4.Text = "";
            textBox1.Text = "";
            textBox2.Text = "";

            Random r = new Random();
            int a = r.Next(97,122);
            textBox1.Text = Convert.ToString ((char)a);
            textBox2.Focus();
        mj = 60;
            label3.Text = "开始计时" + mj.ToString() + "秒";
            timer1.Enabled = true;
            nj = 0;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("初始字母为:"+textBox1 .Text );
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            textBox2.Text = Convert.ToString(e.KeyChar);
            nj++;
            int a = Convert.ToChar (textBox1 .Text);
            int c=(int) a;
            int b = (int)e.KeyChar ;
            if (a > b)
                label4.Text = "太小了!已经" + nj + "秒";
            else if (a < b)
                label4.Text = "太大了!已经" + nj + "秒";

            else
                label4.Text = " 恭喜你猜对了!你共用了" +nj+"秒";

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
                mj--;
                if (mj == 0)
                {
                    label3.Text = "时间到";

                    timer1.Enabled = false;
                }
                else
                    label3.Text = "开始计时" + mj.ToString() + "秒";

        }
    }
}
我在我textbox中输入我猜的数字,会出现两个这个数
搜索更多相关主题的帖子: 移动应用 class private public 开发 
2012-03-01 19:53
快速回复:c#中的移动应用开发 猜字母游戏
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022436 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved