Exemple #1
0
 public MainWindow()
 {
     InitializeComponent();
     AfficherNbRestant();
     textBlockInfo.Text = "Veuillez saisir un Chiffre/ Nombre";
     NbChoisie.Focus();
 }
Exemple #2
0
        private void ValidForm(object sender, RoutedEventArgs e)
        {
            if (NbChoisie.Text != "")
            {
                if (nb > 0)
                {
                    if (nbAleatoire < Convert.ToInt32(NbChoisie.Text))
                    {
                        textBlockInfo.Text = "Le nombre mystère est plus petit";
                        nb--;
                        AfficherNbRestant();
                    }
                    if (nbAleatoire > Convert.ToInt32(NbChoisie.Text))
                    {
                        textBlockInfo.Text = "Le nombre mystère est plus grand";
                        nb--;
                        AfficherNbRestant();
                    }

                    if (nbAleatoire == Convert.ToInt32(NbChoisie.Text))
                    {
                        textBlockInfo.Text  = "Bravo !!! Vous avez trouvé le nombre mystère !";
                        textBlockInfo.Text += $"\nVous avez trouvé en {i} coups.";
                        textBlockInfo.Text += $"\nLe nombre mystère etait {nbAleatoire}.";
                    }
                    i++;
                    NbChoisie.Text = "";
                    NbChoisie.Focus();
                }
                else
                {
                    textBlockInfo.Text = "Perdu !!!";
                    NbChoisie.Focus();
                }
            }
            else
            {
                MessageBox.Show("Veuillez completer tous les champs", "Erreur", MessageBoxButton.OK, MessageBoxImage.Warning);
                NbChoisie.Focus();
            }
        }