Exemplo n.º 1
0
        private bool compare(bool partial)
        {
            string saisie   = textBoxL.Text;
            string controle = Littéral.Int2Lettres(inconnue);

            string[] s1 = saisie.ToLower().Split(" -".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            string[] s2 = controle.ToLower().Split(" -".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            if (partial)
            {
                if (s1.Length == 0)
                {
                    return(false);
                }
                if (s1.Length > s2.Length)
                {
                    return(false);
                }

                for (int i = 0; i < s1.Length - 1; ++i)
                {
                    if (s1[i] != s2[i])
                    {
                        return(false);
                    }
                }

                if (!s2[s1.Length - 1].StartsWith(s1[s1.Length - 1]))
                {
                    return(false);
                }
            }
            else
            {
                if (s1.Length != s2.Length)
                {
                    return(false);
                }
                for (int i = 0; i < s1.Length; ++i)
                {
                    if (s1[i] != s2[i])
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public ResultatCalcul Vérifie(out string resultat)
        {
            resultat = "";

            if (Lettres)
            {
                if (!compare(false))
                {
                    FormErreur.Show("Erreur, ce n'est pas " + inconnue.ToString());

                    resultat = "erreur " + textBoxL.Text;
                    textBoxL.Select();
                    return(ResultatCalcul.Erreur);
                }

                resultat      = textBoxL.Text;
                textBoxL.Text = Littéral.Int2Lettres(inconnue);
            }
            else
            {
                int saisie = textBoxZ.Integer2;

                if (saisie == int.MinValue)
                {
                    FormErreur.Show("TU DOIS ENTRER UN NOMBRE !");
                    return(ResultatCalcul.ErreurSaisie);
                }

                if (saisie != inconnue)
                {
                    FormErreur.Show("Erreur, ce n'est pas ça !");

                    resultat = "erreur " + textBoxL.Text;
                    textBoxZ.Select();
                    return(ResultatCalcul.Erreur);
                }

                resultat = inconnue.ToString();
            }

            buttonCheck.Enabled = false;
            return(ResultatCalcul.OK);
        }
Exemplo n.º 3
0
        public void Encore()
        {
            inconnue = rand.Next(0, Max);

            if (Lettres)
            {
                textBoxL.Text = "";
                textBoxL.Select();

                textBoxZ.Text = inconnue.ToString();
                textBoxZ.Select(0, 0);
            }
            else
            {
                textBoxL.Text = Littéral.Int2Lettres(inconnue);
                textBoxL.Select(0, 0);

                textBoxZ.Text = "";
                textBoxZ.Select();
            }
            buttonCheck.Enabled = true;
        }