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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| <using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace LeNombreMystère
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
int chiffreatrouver = 0;
Random rnd = new Random();
private void Bouton120_Click(object sender, RoutedEventArgs e)
{
labelchiffre.Content = "Choississez un nombre entre 1 et 20";
chiffreatrouver = rnd.Next(1, 21);
}
private void Bouton150_Click(object sender, RoutedEventArgs e)
{
chiffreatrouver = rnd.Next(1, 51);
labelchiffre.Content = "Choississez un nombre entre 1 et 50";
}
private void Bouton1100_Click(object sender, RoutedEventArgs e)
{
chiffreatrouver = rnd.Next(1, 101);
labelchiffre.Content = "Choississez un nombre entre 1 et 100";
}
private void boutonconfirmer_Click(object sender, RoutedEventArgs e)
{
int chiffreuser = 0;
int.TryParse(textboxchiffre.Text, out chiffreuser);
if (Convert.ToString(chiffreuser) != textboxchiffre.Text)
{
MessageBox.Show("Vous devez tapez des chiffres dans la case", "Erreur", MessageBoxButton.OK, MessageBoxImage.Asterisk);
}
if (chiffreatrouver == 0)
{
MessageBox.Show("Choississez quelle tranche de nombre vous voulez via les boutons", "Erreur", MessageBoxButton.OK, MessageBoxImage.Asterisk);
}
else
{
if (chiffreuser > chiffreatrouver) labelchiffre.Content = "C'est moins";
if (chiffreuser < chiffreatrouver) labelchiffre.Content = "C'est plus";
if (chiffreuser == chiffreatrouver)
{
MessageBox.Show("Bravo vous avez trouvé le nombre mystère, cliquez sur les boutons si vous voulez rejouer", "C'est gagné !", MessageBoxButton.OK, MessageBoxImage.Asterisk);
}
}
}
private void Boutonchoisir_Click(object sender, RoutedEventArgs e)
{
}
}
}> |
Partager