Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.8 kB
1
Indexable
Never
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _222
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public int counter = 0;
        public int chet = 3;
        public static int number;


        internal class GameGuessNumber//рандомайзер
        {

            

            private Random rand = new Random();


            public GameGuessNumber()
            {

                number = rand.Next(0, 101);
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            label3.Text = Convert.ToString(chet);
            
        }
        
        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
        private void label3_Click(object sender, EventArgs e)
        {
            label3.Text = chet.ToString();
        }



        private void button1_Click(object sender, EventArgs e)
        {
            int ch;
            string text = textBox1.Text;
            if (int.TryParse(text, out int number))
            {
                ch = Convert.ToInt32(textBox1.Text);
                if (ch < 0 || ch > 100)
                {
                    MessageBox.Show("Вы играете не по правилам!", "Ой-ой");
                }
            else    
                {
                    do
                    {
                        if (ch == number)
                        {
                            MessageBox.Show("Вы угадали!", "Поздравляем!");
                            break;
                        }
                        else
                        {
                            MessageBox.Show("Вы не угадали", "Ой-ой");

                        }


                        counter++;
                        chet = chet - counter;
                    } while (ch != number || counter > 0 || counter < 3);
                    
                    
                }


            }
            
        }
        private void label4_Click(object sender, EventArgs e)
        {

        }

        

       
        private void button2_Click(object sender, EventArgs e)
        {
            if (chet == 0 && counter > 0)
            {
                label3.Text = number.ToString();

            }

            {
                MessageBox.Show("Вы играете не по правилам!", "Ой-ой");
            }


        }
    }
}
    
Leave a Comment