コード例 #1
0
        public Salz(Kation kation, Anion anion)
        {
            Kation = kation;
            Anion  = anion;

            (int anzahlKation, int anzahlAnionen)benoetigeMolekuehle = Ion.BerechneAnzahlMolekuele(kation, anion);
            Kation.Molekuel.Anzahl = benoetigeMolekuehle.anzahlKation;
            Anion.Molekuel.Anzahl  = benoetigeMolekuehle.anzahlAnionen;

            if (Anion.Molekuel.Atombindung.IstElementbindung())
            {
                if (!String.IsNullOrEmpty(Anion.Molekuel.Atombindung.ErhalteElement().Wurzel))
                {
                    Name = Kation.Molekuel.Atombindung.Name + Anion.Molekuel.Atombindung.ErhalteElement().Wurzel.ToLower() + "id";
                }
                else
                {
                    Name = Kation.Molekuel.Atombindung.Name + Anion.Molekuel.Atombindung.ErhalteElement().Name.ToLower() + "id";
                }
            }
            else
            {
                Name = Kation.Molekuel.Atombindung.Name + Anion.Molekuel.Atombindung.Name.ToLower();
            }

            if (Kation.Molekuel.Anzahl > 1)
            {
                if (Kation.Molekuel.Atombindung.IstElementbindung())
                {
                    ChemischeFormel += $"{Kation.Molekuel.Atombindung.ChemischeFormel}{UnicodeHelfer.GetSubscriptOfNumber(Kation.Molekuel.Anzahl)}";
                }
                else
                {
                    ChemischeFormel += $"({Kation.Molekuel.Atombindung.ChemischeFormel}){UnicodeHelfer.GetSubscriptOfNumber(Kation.Molekuel.Anzahl)}";
                }
            }
            else
            {
                ChemischeFormel += $"{Kation.Molekuel.Atombindung.ChemischeFormel}";
            }

            if (Anion.Molekuel.Anzahl > 1)
            {
                if (UnicodeHelfer.GetNumberOfSubscript(Anion.Molekuel.Atombindung.ChemischeFormel.Last()) != -1)
                {
                    ChemischeFormel += $"({Anion.Molekuel.Atombindung.ChemischeFormel}){UnicodeHelfer.GetSubscriptOfNumber(Anion.Molekuel.Anzahl)}";
                }
                else
                {
                    ChemischeFormel += $"{Anion.Molekuel.Atombindung.ChemischeFormel}{UnicodeHelfer.GetSubscriptOfNumber(Anion.Molekuel.Anzahl)}";
                }
            }
            else
            {
                ChemischeFormel += $"{Anion.Molekuel.Atombindung.ChemischeFormel}";
            }
        }