Ejemplo n.º 1
0
 /// <summary>
 /// Ha talált egy motort ami elromlik, akkor megkeresi, hogy melyik autoba van beépítve, és meghívja abban az utoban a váltónak az elromlik metódusát
 /// </summary>
 /// <param name="alkatresz"></param>
 void MelyikAutoBanVan(Alkatresz alkatresz)
 {
     foreach (var item in autok)
     {
         if (item.Motor.Nev == alkatresz.Nev)
         {
             item.Valto.Elromlik();
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Megkeresi az optimalizáció kikötést.
        /// Megkeresi azt az elemet amire a kikötés szól, és aminek mindenképpen benne kell lennie az autoban
        /// </summary>
        public void Kikotes()
        {
            string nevKikotes = "";

            foreach (string item in txtSorai)
            {
                if (item.StartsWith("kikötés"))
                {
                    nevKikotes = item.Split(':')[1];
                }
            }
            alkatreszKikotes = MelyikElem(nevKikotes);
            alkatreszKikotes.Beepit(auto);

            foreach (string item in txtSorai)
            {
                if (item.StartsWith("szempont"))
                {
                    optimalizacioKikotes = item.Split(':')[1];
                }
            }
        }
Ejemplo n.º 3
0
 public void Elromlik(Alkatresz alkatresz)
 {
     Console.WriteLine("Ez az alkatresz elromlott: " + alkatresz.Nev);
 }
Ejemplo n.º 4
0
        public void Backtrack(Alkatresz alkatresz, Auto auto, Alkatresz alkatreszKikotes)
        {
            if (auto.Elektronika != null && auto.Fekrendszer != null && auto.Legszuro != null && auto.Motor != null && auto.Valto != null)
            {
                //Console.WriteLine("Kész az auto");
            }
            else
            {
                int i;
                switch (alkatresz.Tipus)
                {
                case Tipus.motor:
                    if (alkatreszKikotes.Tipus != Tipus.valto)
                    {
                        i = 0;
                        while (alkatreszKikotes.KompatibilisValto != null && i < alkatreszKikotes.KompatibilisValto.Count && auto.Valto == null)
                        {
                            try
                            {
                                alkatreszKikotes.KompatibilisValto[i].Beepit(auto);
                            }
                            catch (BeepitException)
                            {
                                i++;
                            }
                        }
                        if (alkatreszKikotes.KompatibilisValto != null && i > alkatreszKikotes.KompatibilisValto.Count)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                        else if (alkatreszKikotes.KompatibilisValto == null)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                        else if (auto.Valto == null)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                    }
                    if (auto.Valto != null)
                    {
                        Backtrack(auto.Valto, auto, alkatreszKikotes);
                    }
                    break;

                case Tipus.legszuro:
                    if (alkatreszKikotes.Tipus != Tipus.fekrendszer)
                    {
                        i = 0;
                        while (alkatreszKikotes.KompatibilisFekrendszer != null && i < alkatreszKikotes.KompatibilisFekrendszer.Count && auto.Fekrendszer == null)
                        {
                            try
                            {
                                alkatreszKikotes.KompatibilisFekrendszer[i].Beepit(auto);
                            }
                            catch (BeepitException)
                            {
                                i++;
                            }
                        }
                        if (alkatreszKikotes.KompatibilisFekrendszer != null && i > alkatreszKikotes.KompatibilisFekrendszer.Count)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                        else if (alkatreszKikotes.KompatibilisFekrendszer == null)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                        else if (auto.Fekrendszer == null)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                    }
                    if (auto.Fekrendszer != null)
                    {
                        Backtrack(auto.Fekrendszer, auto, alkatreszKikotes);
                    }
                    break;

                case Tipus.fekrendszer:
                    if (alkatreszKikotes.Tipus != Tipus.elektronika)
                    {
                        i = 0;
                        while (alkatreszKikotes.KompatibilisElektronika != null && i < alkatreszKikotes.KompatibilisElektronika.Count && auto.Elektronika == null)
                        {
                            try
                            {
                                alkatreszKikotes.KompatibilisElektronika[i].Beepit(auto);
                            }
                            catch (BeepitException)
                            {
                                i++;
                            }
                        }
                        if (alkatreszKikotes.KompatibilisElektronika != null && i > alkatreszKikotes.KompatibilisElektronika.Count)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                        else if (alkatreszKikotes.KompatibilisElektronika == null)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                        else if (auto.Elektronika == null)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                    }
                    if (auto.Elektronika != null)
                    {
                        Backtrack(auto.Elektronika, auto, alkatreszKikotes);
                    }
                    break;

                case Tipus.elektronika:
                    if (alkatreszKikotes.Tipus != Tipus.motor)
                    {
                        i = 0;
                        while (alkatreszKikotes.KompatibilisMotorok != null && i < alkatreszKikotes.KompatibilisMotorok.Count && auto.Motor == null)
                        {
                            try
                            {
                                alkatreszKikotes.KompatibilisMotorok[i].Beepit(auto);
                            }
                            catch (BeepitException)
                            {
                                i++;
                            }
                        }
                        if (alkatreszKikotes.KompatibilisMotorok != null && i > alkatreszKikotes.KompatibilisMotorok.Count)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                        else if (alkatreszKikotes.KompatibilisMotorok == null)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                        else if (auto.Motor == null)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                    }
                    if (auto.Motor != null)
                    {
                        Backtrack(auto.Motor, auto, alkatreszKikotes);
                    }
                    break;

                case Tipus.valto:
                    if (alkatreszKikotes.Tipus != Tipus.legszuro)
                    {
                        i = 0;
                        while (alkatreszKikotes.KompatibilisLegszuro != null && i < alkatreszKikotes.KompatibilisLegszuro.Count && auto.Legszuro == null)
                        {
                            try
                            {
                                alkatreszKikotes.KompatibilisLegszuro[i].Beepit(auto);
                            }
                            catch (BeepitException)
                            {
                                i++;
                            }
                        }
                        if (alkatreszKikotes.KompatibilisLegszuro != null && i > alkatreszKikotes.KompatibilisLegszuro.Count)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                        else if (alkatreszKikotes.KompatibilisLegszuro == null)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                        else if (auto.Legszuro == null)
                        {
                            throw new NemTalaltAlkatresztException(alkatresz);
                        }
                    }
                    if (auto.Legszuro != null)
                    {
                        Backtrack(auto.Legszuro, auto, alkatreszKikotes);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 5
0
 public AlkatreszException(Alkatresz alkatresz)
 {
     this.alkatresz = alkatresz;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Vissza adja, hogy egy adott alkatrész tartalmazz-e ezt az alkatrészt
 /// </summary>
 bool KompatiblisValamivel(Alkatresz alkatresz)
 {
     return(alkatresz.osszesKompatibilisAlkatresz.Contains(this));
 }
Ejemplo n.º 7
0
 public NemTalaltAlkatresztException(Alkatresz alkatresz) : base(alkatresz)
 {
 }
Ejemplo n.º 8
0
 public BeepitException(Alkatresz alkatresz) : base(alkatresz)
 {
 }