Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- namespace WindowsFormsApp1
- {
- static class Program
- {
- static void Main()
- {
- //utilisation d'une boucle do while au lieu de while afin de mettre à jour la variable msgOK
- String reponse, fin ;
- Boolean msgOK;
- DialogResult test;
- String msg;
- int msgINT;
- int incre = 0;
- Random aleatoire = new Random();
- int chiffre1 = aleatoire.Next(1, 100);
- do
- {
- msg = Jim.InputBox("Input", "Pick a number between 1 and 100", "50");
- msgINT = int.Parse(msg);
- if (msgINT < chiffre1)
- {
- reponse = "It's more !";
- msgOK = false;
- incre++;
- }
- else if (msgINT > chiffre1)
- {
- reponse = "It's less !";
- msgOK = false;
- incre++;
- }
- else
- {
- reponse = "Hurray, you've got the right number !";
- msgOK = true;
- incre++;
- }
- fin = "\t" + msgOK + ", " + reponse + "\n\t" + "Counting your tries : " + incre ;
- test = MessageBox.Show(fin, "Input", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
- } while(msgOK == false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment