Example #1
0
 public void AddBestandteil(Atombindung atombindung, int anzahlAtome)
 {
     for (int cnt = 0; cnt < anzahlAtome; cnt++)
     {
         Bestandteile.Add(atombindung.Bestandteile.SelectMany(x => x).ToArray());
     }
 }
Example #2
0
        public Molekuel ErhalteMolekuel(Atombindung gesuchteAtombindung)
        {
            int anzahlMolekuel = 0;

            foreach (Element[] bestandteil in Bestandteile)
            {
                // Mehr als nur ein Atom vorhanden => Es handelt sich somit um eine Atombindung
                if (bestandteil.Length > 1)
                {
                    // Überprüfe, ob die Sequenz übereinstimmt
                    Element[] atombindungBestandteile = gesuchteAtombindung.Bestandteile.SelectMany(x => x).ToArray();
                    if (bestandteil.Length == atombindungBestandteile.Length)
                    {
                        bool identisch = true;
                        for (int cnt = 0; cnt < bestandteil.Length; cnt++)
                        {
                            if (bestandteil[cnt].Symol.Equals(atombindungBestandteile[cnt].Symol) == false)
                            {
                                identisch = false;
                            }
                        }

                        if (identisch)
                        {
                            anzahlMolekuel++;
                        }
                    }
                }
            }

            if (anzahlMolekuel == 0)
            {
                return(null);
            }

            return(new Molekuel(gesuchteAtombindung, anzahlMolekuel));
        }