摇奖机代码

这是一个使用C#编写的摇奖机程序,通过读取文本文件中的游戏名称、惩罚和人员名单,实现随机选择游戏和惩罚的功能。程序包含多个事件处理函数,如按钮点击事件,用于启动和停止定时器,以及更新显示结果。当指定条件满足时,会从列表中删除已选中的惩罚选项,确保不会重复抽到。
摘要由CSDN通过智能技术生成

public partial class Form1 : Form
    {
        string[] chengfa = null;
        string[] Games = null;
        string[] names = null;
        int i = 0;
        int a = 0;
        int b = 0;
        string name = "";
        string name1 = "";
        public Form1()
        {
            InitializeComponent();
            Games = File.ReadAllLines(Application.StartupPath + "/游戏.txt", Encoding.Default);
            chengfa = File.ReadAllLines(Application.StartupPath + "/惩罚.txt", Encoding.Default);
            names = File.ReadAllLines(Application.StartupPath + "/人员名单.txt", Encoding.Default);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.timer2.Stop();
            this.timer3.Stop();
            this.timer1.Start();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.timer1.Stop();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.timer1.Stop();
            this.timer3.Stop();
            this.timer2.Start();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.timer2.Stop();
            ArrayList ii = new ArrayList(chengfa);//把chengfa数组复制到ArrayLise中,便于删除

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值