Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace GameRandomNubmer
- {
- public partial class Form1 : Form
- {
- private Random random;
- private int numbRandom;
- public Form1()
- {
- InitializeComponent();
- }
- protected override void OnLoad(EventArgs e)
- {
- CalculateRandomNumber();
- }
- private void EnterButtonClick(object sender, EventArgs e)
- {
- int textBoxNumber = int.Parse(textBox1.Text);
- if (textBoxNumber == numbRandom)
- textBox2.Text = "You win!!!";
- else
- {
- textBox2.Text = "Try again";
- textBox1.Text = string.Empty;
- }
- }
- private void NewButtonClick(object sender, EventArgs e)
- {
- CalculateRandomNumber();
- }
- private void textBox1_MouseClick(object sender, MouseEventArgs e)
- {
- ClearTextBoxs();
- }
- private void CalculateRandomNumber()
- {
- random = new Random();
- numbRandom = random.Next(1, 10);
- if ((textBox1.Text != string.Empty) && (textBox2.Text != string.Empty))
- ClearTextBoxs();
- }
- private void ClearTextBoxs()
- {
- textBox1.Text = textBox2.Text = string.Empty;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement