hi^^
Ich mache derzeit eine Lehre als Informatiker und habe als aufgabe bekommen ein Würfelpoker progi zu programmieren.
Wäre auch schon fertig, jedoch sind da unlogische Fehler die behaupten, dass die var nich befüllt ist oO. Seht selbst^^
Bitte um hilfe, ich bin am verzweiflen.... btw ich arbeite mit VS2008.
mfg,
eViL_aLekS
Ich mache derzeit eine Lehre als Informatiker und habe als aufgabe bekommen ein Würfelpoker progi zu programmieren.
Wäre auch schon fertig, jedoch sind da unlogische Fehler die behaupten, dass die var nich befüllt ist oO. Seht selbst^^
Code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Würfelpoker { public partial class Würfelpoker : Form { public Würfelpoker() { InitializeComponent(); } private void Würfeln_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { string c1,c2; int a,aa,aaa,aaaa,aaaaa; // ich weiß, ich sollte sprechendere var verwenden xD Random rand = new Random(); a=rand.Next(1,7); //ich erstelle eine Randomzahl if (a == 1 && w1.Enabled==true) //wegen dem hold habe ich es so gemacht, dass wenn der user den würfel behalten will und er ihn anklickt, dieser auf false gesetzt wird und somit der würfel nich verändert wird. { c1 = "C:\\1.jpg"; // ich speichere den pfad der bilder als text, damit ich ihn dann vergleichen kann wenn 2 pfade gleich sind ist es ein pärchen. w1.Load("C:\\1.jpg"); } else if (a == 2 && w1.Enabled == true) { c1 = "C:\\2.jpg"; w1.Load("C:\\2.jpg"); } else if (a == 3 && w1.Enabled == true) { c1 = "C:\\3.jpg"; w1.Load("C:\\3.jpg"); } else if (a == 4 && w1.Enabled == true) { c1 = "C:\\4.jpg"; w1.Load("C:\\4.jpg"); } else if (a == 5 && w1.Enabled == true) { c1 = "C:\\5.jpg"; w1.Load("C:\\5.jpg"); } else if (a == 6 && w1.Enabled == true) { c1 = "C:\\6.jpg"; w1.Load("C:\\6.jpg"); } Random rando = new Random(); aa = rando.Next(1,7); if (aa == 1 && w2.Enabled == true) { c2 = "C:\\5.jpg"; w2.Load("C:\\5.jpg"); } else if (aa == 2 && w2.Enabled == true) { c2 = "C:\\3.jpg"; w2.Load("C:\\3.jpg"); } else if (aa == 3 && w2.Enabled == true) { c2 = "C:\\1.jpg"; w2.Load("C:\\1.jpg"); } else if (aa == 4 && w2.Enabled == true) { c2 = "C:\\4.jpg"; w2.Load("C:\\4.jpg"); } else if (aa == 5 && w2.Enabled == true) { c2 = "C:\\2.jpg"; w2.Load("C:\\2.jpg"); } else if (aa == 6 && w2.Enabled == true) { c2 = "C:\\6.jpg"; w2.Load("C:\\6.jpg"); } Random random = new Random(); aaa = random.Next(1,7); if (aaa == 1 && w3.Enabled == true) { w3.Load("C:\\6.jpg"); } else if (aaa == 2 && w3.Enabled == true) { w3.Load("C:\\5.jpg"); } else if (aaa == 3 && w3.Enabled == true) { w3.Load("C:\\4.jpg"); } else if (aaa == 4 && w3.Enabled == true) { w3.Load("C:\\2.jpg"); } else if (aaa == 5 && w3.Enabled == true) { w3.Load("C:\\3.jpg"); } else if (aaa == 6 && w3.Enabled == true) { w3.Load("C:\\1.jpg"); } Random randomm = new Random(); aaaa = randomm.Next(6); if (aaa == 1 && w4.Enabled == true) { w4.Load("C:\\2.jpg"); } else if (aaa == 2 && w4.Enabled == true) { w4.Load("C:\\4.jpg"); } else if (aaa == 3 && w4.Enabled == true) { w4.Load("C:\\6.jpg"); } else if (aaa == 4 && w4.Enabled == true) { w4.Load("C:\\1.jpg"); } else if (aaa == 5 && w4.Enabled == true) { w4.Load("C:\\2.jpg"); } else if (aaa == 6 && w4.Enabled == true) { w4.Load("C:\\3.jpg"); } Random randommm = new Random(); aaaaa = randommm.Next(6); if (aaa == 1 && w5.Enabled == true) { w5.Load("C:\\3.jpg"); } else if (aaa == 2 && w5.Enabled == true) { w5.Load("C:\\2.jpg"); } else if (aaa == 3 && w5.Enabled == true) { w5.Load("C:\\6.jpg"); } else if (aaa == 4 && w5.Enabled == true) { w5.Load("C:\\1.jpg"); } else if (aaa == 5 && w5.Enabled == true) { w5.Load("C:\\5.jpg"); } else if (aaa == 6 && w5.Enabled == true) { w5.Load("C:\\3.jpg"); } if (c1 == c2) //da zeigt er mir jedoch die fehler an. Undzwar meint er: "verwendung der nicht zugewiesenen lokalen variable c1/c2....." ich hab mit f11 nachgeschaut, und siehe da, in der var stehen die pfade als text drinnen... normalerweise kann man ja txt vergleichen. { MessageBox.Show("Sie haben ein Pärchen"); } } private void w1_Click(object sender, EventArgs e) { /*int i=0; do{ w1.Enabled = false; }while(i<=3); w1.Enabled = true;*/ w1.Enabled = false; pictureBox1.Visible = true; } private void w2_Click(object sender, EventArgs e) { w2.Enabled = false; pictureBox2.Visible = true; } private void w3_Click(object sender, EventArgs e) { w3.Enabled = false; pictureBox3.Visible = true; } private void w4_Click(object sender, EventArgs e) { w4.Enabled = false; pictureBox4.Visible = true; } private void w5_Click(object sender, EventArgs e) { w5.Enabled = false; pictureBox5.Visible = true; } private void button1_Click_1(object sender, EventArgs e) { w1.Enabled = true; pictureBox1.Visible = false; w2.Enabled = true; pictureBox2.Visible = false; w3.Enabled = true; pictureBox3.Visible = false; w4.Enabled = true; pictureBox4.Visible = false; w5.Enabled = true; pictureBox5.Visible = false; } } }
Bitte um hilfe, ich bin am verzweiflen.... btw ich arbeite mit VS2008.
mfg,
eViL_aLekS
Comment