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 Lab6B
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int number;
private void Form1_Load(object sender, EventArgs e)
{
Random generator = new Random();
number = generator.Next(1, 101);
}
private void button1_Click(object sender, EventArgs e)
{
int guess = Convert.ToInt32(Guess.Text);
if (Guess.Text != string.Empty)
{
if (guess < number)
{
Evaluate.Visible = false;
label2.Visible = true;
label2.Text = "Too Low!";
Clear.Visible = true;
BackColor = Color.LightSeaGreen;
}
else if (guess > number)
{
Evaluate.Visible = false;
label2.Visible = true;
label2.Text = "Too High!";
Clear.Visible = true;
BackColor = Color.SlateBlue;
}
else
{
MessageBox.Show("You are right! It took you {0} guesses.");
}
}
}
private void button2_Click(object sender, EventArgs e)
{
Guess.Text = "";
Evaluate.Visible = true;
label2.Visible = false;
Clear.Visible = false;
BackColor = Color.PowderBlue;
}
private void label2_Click(object sender, EventArgs e)
{
}
}
}
|