Platzierungen aus zwei Tabellen vergleichen und ordnen
-
Hallo zusammen,
ich bastel mir gerade eine Turnierprogramm für unseren Fussballverein. Habe nun die gesamte Auswertung hinbekommen, so dass Gruppe A und Gruppe B richtig berechnet und sortiert wird. Nun möchte ich am Ende die Platzierungen in den Gruppen A und B miteinander vergleichen und der Abschlusstabelle zuordnen. Doch irgendwie mache ich etwas falsch, denn er sortiert vergleicht mir das stellenweise falsch.
Anbei mal meine Auswertung, bin auch gern für weitere Vorschläge offen, wie ich dies möglicherweise einfacher machen kann.
tempTabPktA3 = Convert.ToSingle(textBoxPktTabA3.Text); tempTabPktB3 = Convert.ToSingle(textBoxPktTabB3.Text); tempTabTDiffA3 = Convert.ToSingle(textBoxTDiffTabA3.Text); tempTabTDiffB3 = Convert.ToSingle(textBoxTDiffTabB3.Text); tempTabTPA3 = Convert.ToSingle(textBoxTPTabA3.Text); tempTabTPB3 = Convert.ToSingle(textBoxTPTabB3.Text); tempTabTNA3 = Convert.ToSingle(textBoxTNTabA3.Text); tempTabTNB3 = Convert.ToSingle(textBoxTNTabB3.Text); if (tempTabPktA3 > tempTabPktB3) { textBoxPlatz5.Text = textBoxVerTabA3.Text; textBoxPlatz6.Text = textBoxVerTabB3.Text; return; } else if (tempTabPktA3 < tempTabPktB3) { textBoxPlatz5.Text = textBoxVerTabB3.Text; textBoxPlatz6.Text = textBoxVerTabA3.Text; return; } else if (tempTabTDiffA3 > tempTabTDiffB3 && tempTabPktA3 == tempTabPktB3) { textBoxPlatz5.Text = textBoxVerTabA3.Text; textBoxPlatz6.Text = textBoxVerTabB3.Text; return; } else if (tempTabTDiffA3 < tempTabTDiffB3 && tempTabPktA3 == tempTabPktB3) { textBoxPlatz5.Text = textBoxVerTabB3.Text; textBoxPlatz6.Text = textBoxVerTabA3.Text; return; } else if (tempTabTPA3 > tempTabTPB3 && tempTabPktA3 == tempTabPktB3 && tempTabTDiffA3 == tempTabTDiffB3) { textBoxPlatz5.Text = textBoxVerTabA3.Text; textBoxPlatz6.Text = textBoxVerTabB3.Text; return; } else if (tempTabTPA3 < tempTabTPB3 && tempTabPktA3 == tempTabPktB3 && tempTabTDiffA3 == tempTabTDiffB3) { textBoxPlatz5.Text = textBoxVerTabB3.Text; textBoxPlatz6.Text = textBoxVerTabA3.Text; return; } else if (tempTabTNA3 > tempTabTNB3 && tempTabPktA3 == tempTabPktB3 && tempTabTDiffA3 == tempTabTDiffB3 && tempTabTPA3 == tempTabTPB3) { textBoxPlatz5.Text = textBoxVerTabB3.Text; textBoxPlatz6.Text = textBoxVerTabA3.Text; return; } else if (tempTabTNA3 < tempTabTNB3 && tempTabPktA3 == tempTabPktB3 && tempTabTDiffA3 == tempTabTDiffB3 && tempTabTPA3 == tempTabTPB3) { textBoxPlatz5.Text = textBoxVerTabA3.Text; textBoxPlatz6.Text = textBoxVerTabB3.Text; return; } tempTabPktA3 = 0; tempTabPktB3 = 0; tempTabTDiffA3 = 0; tempTabTDiffB3 = 0; tempTabTPA3 = 0; tempTabTPB3 = 0; tempTabTNA3 = 0; tempTabTNB3 = 0;
Dieser Code ist mal beispielhaft für die Endplatzierungen 5 & 6. Es werden jeweils die Werte des drittplatzierten in der Gruppe A mit der des in Gruppe B verglichen. Erst nach Punkten, dann nach Tordifferenz, dann geschossene Tore(TP) und am Ende nach kassierten Toren (TN).
Mein Gefühl ist, dass ich das mit den else if Anweisugnen falsch habe, doch ich komme nicht darauf.
Wäre super wenn mit jemand helfen könnte.
-
Deine ganze Herangehensweise ist falsch: benutze Arrays (bzw. generische Listen) und dessen Sort-Methode.