Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- namespace WindowsFormsApp1
- {
- public partial class Form1 : Form
- {
- private static int x = 0;
- private static int y = 0;
- private static int rightAnswer = 0;
- private static int bal = 0;
- private static int step = 1;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- GenerateUrav(ref x, ref y, ref rightAnswer);
- }
- private void GenerateUrav(ref int x, ref int y, ref int right)
- {
- Random random = new Random();
- x = random.Next(1,21);
- y = random.Next(1,21);
- right = x + y;
- label1.Text = $"{x} + {y} = ";
- }
- private void button1_Click(object sender, EventArgs e)
- {
- step++;
- if (step <= 5)
- {
- label2.Text = $"{step}/5";
- if (textBox1.Text != "")
- {
- if (textBox1.Text == rightAnswer.ToString())
- {
- MessageBox.Show("Правильно!");
- bal++;
- }
- else
- {
- MessageBox.Show("Неправильно!");
- }
- }
- else
- {
- MessageBox.Show("Неправильный ввод!");
- }
- }
- else
- {
- if (bal == 5)
- MessageBox.Show("Отлично!");
- else if (bal == 4)
- MessageBox.Show("Хорошо!");
- else if(bal == 3)
- MessageBox.Show("Удовлетворительно");
- else
- MessageBox.Show("Плохо");
- bal = 0;
- step = 1;
- label2.Text = $"{step}/5";
- }
- GenerateUrav(ref x, ref y, ref rightAnswer);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment