本文介绍了如何修改代码,以便每两个相同数字的插槽将添加10个硬币,30个硬币为3个,100个硬币为7 7 7。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Microsoft Visual Studio 2010中,谢谢



我尝试过:



In Microsoft Visual Studio 2010, Thank you

What I have tried:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Lucky_Seven
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            Random rnd = new Random();
            lblSlot1.Text = Convert.ToString(rnd.Next(1, 8));

            Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
            lblSlot1.ForeColor = randomColor;
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            Random rnd = new Random();
            lblSlot2.Text = Convert.ToString(rnd.Next(1, 8));

            Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
            lblSlot2.ForeColor = randomColor;
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            Random rnd = new Random();
            lblSlot3.Text = Convert.ToString(rnd.Next(1, 8));

            Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
            lblSlot3.ForeColor = randomColor;
        }

        private void cmdPlay_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            timer2.Enabled = true;
            timer3.Enabled = true;
            cmdPlay.Enabled = false;
            cmdStop.Enabled = true;

        }

        private void cmdStop_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            timer2.Enabled = false;
            timer3.Enabled = false;
            cmdPlay.Enabled = true;
            cmdStop.Enabled = false;

            if (lblSlot1.Text == lblSlot2.Text)
            {
                int coins;
                coins = Convert.ToInt16(lblCoins.Text) + 10;
                lblCoins.Text = Convert.ToString(coins);
            }
            
            
        }

        private void cmdQuit_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Are you sure you want to quit?", "Lucky Seven", MessageBoxButtons.YesNo);
            switch (dr)
            {
                case DialogResult.Yes:
                    Application.Exit();
                    break;
                case DialogResult.No:
                    MessageBox.Show("Quitting applicationjcanceled","LuckySeven");
                    break;

        }
    }
    }
}

推荐答案

HashSet<int> hs = new HashSet<int>();
hs.Add(1);
hs.Add(4);
hs.Add(1);
Console.WriteLine(hs.Count);


这篇关于如何修改代码,以便每两个相同数字的插槽将添加10个硬币,30个硬币为3个,100个硬币为7 7 7。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 18:21