public Lauge(Metall metall) { // Erstelle das Hydroxid Oxid hydroxid = new Oxid("OH"); // Berechne die Anzahl der Moleküle (int anzahlMetall, int anzahlHydroxid) = MolekuelHelfer.BerechneAnzahlDerMolekuele(metall.Hauptgruppe, -1); // Füge die Moleküle als Bestandteil der Lauge hinzu AddBestandteil(metall, anzahlMetall); AddBestandteil(hydroxid, anzahlHydroxid); // Setze die Bestandteile Metall = ErhalteMolekuel(metall); Hydroxid = ErhalteMolekuel(hydroxid); // Generiere die chemische Formel und den Namen Name = Metall.Atombindung.ErhalteElement().Name + "hydroxid"; ChemischeFormel = GeneriereChemischeFormelAusBestandteilen(fuerAnzeige: false); }
public byte[] ToObjref() { MemoryStream stm = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stm); writer.Write(Encoding.ASCII.GetBytes("MEOW")); writer.Write(1); writer.Write(Iid.ToByteArray()); writer.Write(0); writer.Write(1); writer.Write(Oxid.ToByteArray(), 0, 8); RandomNumberGenerator rng = RandomNumberGenerator.Create(); byte[] oid = new byte[8]; rng.GetBytes(oid); writer.Write(oid); writer.Write(Ipid.ToByteArray()); writer.Write(0); return(stm.ToArray()); }
private void GeneriereGleichungen_Click(object sender, RoutedEventArgs e) { MetalloxidEingabeTextBox.TextDocument.GetText(Windows.UI.Text.TextGetOptions.UseObjectText, out string metalloxidSymbol); if (String.IsNullOrEmpty(metalloxidSymbol)) { // Suche nun in der DropDown if (MetalloxidAuswahlComboBox.SelectedIndex == -1) { return; } metalloxidSymbol = (string)((ComboBoxItem)MetalloxidAuswahlComboBox.SelectedValue).Tag; } SaeureEingabeTextBox.TextDocument.GetText(Windows.UI.Text.TextGetOptions.UseObjectText, out string saeureFormel); if (String.IsNullOrEmpty(saeureFormel)) { // Suche nun in der DropDown if (SaeureAuswahlComboBox.SelectedIndex == -1) { return; } saeureFormel = (string)((ComboBoxItem)SaeureAuswahlComboBox.SelectedValue).Tag; } Saeure säure = new Saeure(saeureFormel); Oxid metalloxid = new Oxid(metalloxidSymbol); MetalloxidSaeureReaktion reaktion = new MetalloxidSaeureReaktion(metalloxid, säure); reaktion.BeginneReaktion(); ReaktionsgleichungenControl.ItemsSource = new List <Object>(); ReaktionsgleichungenControl.ItemsSource = reaktion.ReaktionsResultate; }
public MetalloxidSaeureReaktion(Oxid metalloxid, Saeure saeure) { ReagierendesMetalloxid = metalloxid; ReagierendeSaeure = saeure; ReaktionsResultate = new List <MetalloxidSaeureReaktionsResultat>(); }
private (string saureName, string oxidName) GeneriereNameElementsauerstoffsaeure(int anzahlWasserstoffAtome, Oxid oxid) { string oxidName = null; string saureName = null; // Es handelt sich um Elemente im Periodensystem, somit geben die // Valenzelektronen über die stabile Oxidationsstufe eine Aussage int oxidationsstufeRestelement = oxid.ErhalteRestOxidationsstufe(-anzahlWasserstoffAtome); if (oxid.Bindungspartner.Atombindung.ErhalteElement().Hauptgruppe != 7 && oxid.Bindungspartner.Atombindung.ErhalteElement().Hauptgruppe != 8) { if (oxidationsstufeRestelement == oxid.Bindungspartner.Atombindung.ErhalteElement().Hauptgruppe) { // Ist eine gebräuchliche Oxidationsstufe if (String.IsNullOrEmpty(oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel)) { oxidName = oxid.Bindungspartner.Atombindung.ErhalteElement().Name + "at"; } else { oxidName = oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel + "at"; } } else if (oxidationsstufeRestelement == oxid.Bindungspartner.Atombindung.ErhalteElement().Hauptgruppe - 2) { if (String.IsNullOrEmpty(oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel)) { oxidName = oxid.Bindungspartner.Atombindung.ErhalteElement().Name + "it"; } else { oxidName = oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel + "it"; } } else if (oxidationsstufeRestelement == oxid.Bindungspartner.Atombindung.ErhalteElement().Hauptgruppe - 4) { if (String.IsNullOrEmpty(oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel)) { oxidName = "Hypo" + oxid.Bindungspartner.Atombindung.ErhalteElement().Name.ToLower() + "it"; } else { oxidName = "Hypo" + oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel.ToLower() + "it"; } } } else { if (oxidationsstufeRestelement == oxid.Bindungspartner.Atombindung.ErhalteElement().Hauptgruppe) { // Ist eine gebräuchliche Oxidationsstufe if (String.IsNullOrEmpty(oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel)) { oxidName = "Per" + oxid.Bindungspartner.Atombindung.ErhalteElement().Name + "at"; } else { oxidName = "Per" + oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel + "at"; } } else if (oxidationsstufeRestelement == oxid.Bindungspartner.Atombindung.ErhalteElement().Hauptgruppe - 2) { if (String.IsNullOrEmpty(oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel)) { oxidName = oxid.Bindungspartner.Atombindung.ErhalteElement().Name + "at"; } else { oxidName = oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel + "at"; } } else if (oxidationsstufeRestelement == oxid.Bindungspartner.Atombindung.ErhalteElement().Hauptgruppe - 4) { if (String.IsNullOrEmpty(oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel)) { oxidName = oxid.Bindungspartner.Atombindung.ErhalteElement().Name.ToLower() + "it"; } else { oxidName = oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel.ToLower() + "it"; } } else if (oxidationsstufeRestelement == oxid.Bindungspartner.Atombindung.ErhalteElement().Hauptgruppe - 6) { if (String.IsNullOrEmpty(oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel)) { oxidName = "Hypo" + oxid.Bindungspartner.Atombindung.ErhalteElement().Name.ToLower() + "it"; } else { oxidName = "Hypo" + oxid.Bindungspartner.Atombindung.ErhalteElement().Wurzel.ToLower() + "it"; } } } if (String.IsNullOrEmpty(oxidName)) { throw new Exception("Unbekannter Name des Oxids."); } if (oxidName.Substring(oxidName.Length - 2).Equals("at")) { saureName = oxid.Bindungspartner.Atombindung.ErhalteElement().Name + "säure"; } else if (oxidName.Substring(oxidName.Length - 2).Equals("it")) { saureName = oxid.Bindungspartner.Atombindung.ErhalteElement().Name + "ige Säure"; } else { throw new Exception("Name konnte nicht ermittelt werden. Unbekannte Endung des Oxids."); } return(saureName, oxidName); }