Example #1
0
        public void simple()
        {
            //enlever les transitions complexes
            foreach (Transition t in list_transition)
            {
                Etat etat = t.initial;
                if (t.car.LongCount() != 1)
                {
                    for (int i = 1; i < t.car.LongCount(); i++)
                    {
                        Etat       et = new Etat(false);
                        Transition tr = new Transition(etat, et);
                        tr.car[0] = t.car[i - 1];
                        if (i == 1)
                        {
                            etat.list_etat_suiv.Remove(t.final);
                        }
                        etat.list_etat_suiv.Add(et);
                        list_transition.Add(tr);
                        list_etat.Add(et);
                        etat = et;
                    }
                    list_transition.Remove(t);
                }
            }

            //enlever les #
            Boolean repeat = true;

            while (repeat == true)
            {
                repeat = false;
                foreach (Transition tran in list_transition)
                {
                    if (tran.car[0] == '#')
                    {
                        repeat = true;
                        Etat fin  = tran.final;
                        Etat init = tran.initial;
                        list_transition.Remove(tran);
                        if (fin.list_transition_partant.LongCount() == 0)
                        {
                            init.final = true;
                            //sauvegarder dans liste detats
                        }
                        else
                        {
                            foreach (Transition et in fin.list_transition_partant)
                            {
                                Transition tr = new Transition(tran.initial, et.final);
                                tr.car[0] = et.car[0];
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        public void miroir()
        {
            Etat e = new Etat(false);

            foreach (Etat et in list_etat)
            {
                if (et.final == true)
                {
                    Transition t = new Transition(et, e);
                    t.car[0] = '#';
                    list_transition.Add(t);
                }
                for (int i = 0; i < list_transition.LongCount(); i++)
                {
                    list_transition[i].inverser();
                }
            }
        }
Example #3
0
        public List <Etat> complement()
        {
            Etat        et   = new Etat(true);
            Boolean     bl   = false;
            List <Etat> list = new List <Etat>();

            foreach (Etat e in list_etat)
            {
                foreach (Char c in alph)
                {
                    int     i = 0;
                    Boolean b = false;
                    while (b == false && i < e.list_transition_partant.LongCount())
                    {
                        if (e.list_transition_partant[i].car[0] == c)
                        {
                            b = true; bl = true;
                        }
                        i++;
                    }
                    if (b == false)
                    {
                        Transition t = new Transition(e, et);
                        t.car[0] = c;
                        list_transition.Add(t);
                    }
                }
                if (e.final == true)
                {
                    e.final = true;
                }
                else
                {
                    e.final = false;
                }
                list.Add(e);
                if (bl == true)
                {
                    list.Add(et);
                }
            }
            return(list);
        }
Example #4
0
        public Automate()
        {
            Console.Out.WriteLine("definissez l'alphabet ");
            Console.Out.WriteLine("donnez le nbre de lettres ");

            int n = Int16.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                Console.Out.WriteLine("donnez la lettre suivante ");
                alph.Add(Console.ReadLine()[0]);
            }
            Console.Out.WriteLine("donnez le nbre d'etats ");
            nb_etat = Int16.Parse(Console.ReadLine());
            int nb_trans;

            for (int i = 0; i < nb_etat; i++)
            {
                Etat etat;
                Console.Out.WriteLine("le'etats " + i + " et il final ? ");
                if (Int16.Parse(Console.ReadLine()) == 0)
                {
                    etat = new Etat(true);
                }
                else
                {
                    etat = new Etat(false);
                }
                list_etat.Add(etat);
            }
            foreach (Etat etat in list_etat)
            {
                Console.Out.WriteLine("donnez le nbre de transitions partant de l'etat s" + etat.id);
                nb_trans = Int16.Parse(Console.ReadLine());
                for (int i = 0; i < nb_trans; i++)
                {
                    //String s = Console.ReadLine();
                    Console.Out.WriteLine("donnez l'etat d'arrivé(s" + i + "):");

                    int  b   = Int16.Parse(Console.ReadLine());
                    Etat ett = new Etat(true);
                    //Complex_etat ettc = new Complex_etat();

                    foreach (Etat et in list_etat)
                    {
                        if (b == et.id)
                        {
                            ett = et;
                            break;
                        }
                    }
                    etat.list_etat_suiv.Add(ett);
                    //etat.list_etat_complex_suiv.Add(ettc);


                    Transition transition = new Transition(etat, ett);
                    Console.Out.WriteLine("construis la chaine");
                    Console.Out.WriteLine("donnez le nbre de lettres de votre chaine ");
                    int k = Console.ReadLine()[0];
                    for (int j = 0; j < k; j++)
                    {
                        ;
                    }
                    {
                        transition.car.Add(Console.ReadLine()[0]);
                    }
                    list_transition.Add(transition);
                    etat.list_transition_partant.Add(transition);
                }
            }
        }