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
| public void CheckReponse(string bonnereponse) // Fonction servant à vérifier la réponse des utilisateurs
{
const string PICJUSTE = @"c:\Quizz\Image\Juste.gif"; // chemin de l'image correcte
const string PICFAUX = @"c:\Quizz\Image\Faux.gif"; // chemin de l'image fausse
int Ref = 0; // Quel optR a été séléctionné
pctI1.Image = null;
pctI2.Image = null;
pctI3.Image = null;
// Test affectant la variable de référence
if (optR1.Checked) Ref = 1;
if (optR2.Checked) Ref = 2;
if (optR3.Checked) Ref = 3;
try
{
Thread.Sleep(250);
switch (Ref) // regarde l'élément séléctionné verifie si il est juste et ajoute l'image et incrémente le score.
{
case 0: // si rien n'est séléctionné
MessageBox.Show("Vous devez sélectionnée une réponse");
QuestionCourante--; // on décrémente la question courante étant donnée qu'elle a fait un saut lors du clique
break;
case 1: // si optR1 a été séléctionné
if (optR1.Text == LeQuizz[QuestionCourante - 1].BonneRéponse) // si la réponse est correct
{
pctI1.Image = new Bitmap(PICJUSTE);
Score++;
}
else
{ // si la réponse est incorrecte
pctI1.Image = new Bitmap(PICFAUX);
}
break;
case 2: // si optR2 a été sélectionné
if (optR2.Text == LeQuizz[QuestionCourante - 1].BonneRéponse)
{
pctI2.Image = new Bitmap(PICJUSTE);
Score++;
}
else
{
pctI2.Image = new Bitmap(PICFAUX);
}
break;
case 3: // si optR3 a été séléctionné
if (optR3.Text == LeQuizz[QuestionCourante - 1].BonneRéponse) // si la réponse est correcte
{
pctI3.Image = new Bitmap(PICJUSTE);
Score++;
}
else // si la réponse est fausse
{
pctI3.Image = new Bitmap(PICFAUX);
}
break;
}
}
catch (Exception ex) { MessageBox.Show("L'erreur suivante est apparue: " + ex.ToString()); }
} |
Partager