1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private Random _random;
public Form1()
{
InitializeComponent();
_random = new Random();
}
private void button1_Click(object sender, EventArgs e)
{
//En mettant cette ligne ici, vous créez un nouvel objet Random à chaque clic. D'où le nouveau nombre à chaque clic sur le bouton ;)
//Random random = new Random();
int valeur1 = _random.Next(1, 10);
int valeur2 = _random.Next(1, 10);
int valeur3 = _random.Next(1, 10);
int valeur4 = _random.Next(1, 10);
if (numericUpDown1.Value == valeur1 && numericUpDown2.Value == valeur1 && numericUpDown3.Value == valeur1 && numericUpDown4.Value == valeur1)
{
MessageBox.Show("bravo tout les nombre on ete trouvé");
}
if (numericUpDown1.Value == valeur1)
{
MessageBox.Show("nombre 1 trouvé");
}
else
{
MessageBox.Show("nombre incorecte");
}
}
}
} |