Arama butonu
Bu konudaki kullanıcılar: 1 misafir, 1 mobil kullanıcı
5
Cevap
512
Tıklama
0
Öne Çıkarma
c sharp ödev sorunum
İ
9 yıl
Onbaşı
Konu Sahibi

benim kart eşleştirme oyunu hakkında ödevim var ancak c#'ım çok gelişmiş olmadıgı için ödevi for döngüsü ile yapmayı denedim ancak yeterli değil yardımcı olabilirmisiniz.şunlarda kodlarım

for (int x = 0,y = 0,z=0; x != 3 && y != 3 && z != 3;)
{
x = 0;
y = 0;
z = 0;
Random sayi = new Random();
int butn1 = sayi.Next(1, 4);
if (butn1 == 1)
x = x + 1;
else if (butn1 == 2)
y = y + 1;
else if (butn1 == 3)
z = z + 1;
button1.Text = (butn1).ToString();
int butn2 = sayi.Next(1, 4);
if (butn2 == 1)
x = x + 1;
else if (butn2 == 2)
y = y + 1;
else if (butn2 == 3)
z = z + 1;
button2.Text = (butn2).ToString();
int butn3 = sayi.Next(1, 4);
if (butn3 == 1)
x = x + 1;
else if (butn3 == 2)
y = y + 1;
else if (butn3 == 3)
z = z + 1;
button3.Text = (butn3).ToString();
int butn4 = sayi.Next(1, 4);
if (butn4 == 1)
x = x + 1;
else if (butn4 == 2)
y = y + 1;
else if (butn4 == 3)
z = z + 1;
button4.Text = (butn4).ToString();
int butn5 = sayi.Next(1, 4);
if (butn5 == 1)
x = x + 1;
else if (butn5 == 2)
y = y + 1;
else if (butn5 == 3)
z = z + 1;
button5.Text = (butn5).ToString();
int butn6 = sayi.Next(1, 4);
if (butn6 == 1)
x = x + 1;
else if (butn6 == 2)
y = y + 1;
else if (butn6 == 3)
z = z + 1;
button6.Text = (butn6).ToString();
int butn7 = sayi.Next(1, 4);
if (butn7 == 1)
x = x + 1;
else if (butn6 == 2)
y = y + 1;
else if (butn6 == 3)
z = z + 1;
button7.Text = (butn7).ToString();
int butn8 = sayi.Next(1, 4);
if (butn8 == 1)
x = x + 1;
else if (butn8 == 2)
y = y + 1;
else if (butn8 == 3)
z = z + 1;
button8.Text = (butn8).ToString();
int butn9 = sayi.Next(1, 4);
if (butn9 == 1)
x = x + 1;
else if (butn9 == 2)
y = y + 1;
else if (butn9 == 3)
z = z + 1;
button9.Text = (butn9).ToString();
}



G
9 yıl
Yarbay

kart oyununu anlat bakayım nedir ona göre bakalım yani tam olarak nasıl oynanıyor



H
9 yıl
Teğmen

Oyunun mantigi ne soylersen belki yardimci olabilirim





< Bu mesaj bu kişi tarafından değiştirildi hannibal1903 -- 29 Kasım 2015; 21:48:04 >

< Bu ileti mini sürüm kullanılarak atıldı >
Bu mesaja 1 cevap geldi.

Bu mesajda bahsedilenler: @ironbug55
İ
9 yıl
Onbaşı
Konu Sahibi

oyunun mantığı şu şekilde tüm kartlar kapalı 2 kartı seçtiğinizde eğer eşleşirse puan kazanıyorsunuz hepsini açtığınızda oyun bitiyor


Bu mesaja 1 cevap geldi.

Bu mesajda bahsedilenler: @hannibal1903
İ
9 yıl
Onbaşı
Konu Sahibi

int x = 0;
int y = 0;
int z = 0;
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int q = 0;
sayac = 0;
timer1.Enabled = true;
for (; x != 2 || y != 2 || z != 2 || a != 2 || b !=2 || c !=2 || d !=2 || q !=2; )
{
x = 0;
y = 0;
z = 0;
a = 0;
b = 0;
c = 0;
d = 0;
q = 0;
Random sayi = new Random();
int butn1 = sayi.Next(1, 9);
if (butn1 == 1)
x = x + 1;
else if (butn1 == 2)
y = y + 1;
else if (butn1 == 3)
z = z + 1;
else if (butn1 == 4)
a = a + 1;
else if (butn1 == 5)
b = b + 1;
else if (butn1 == 6)
c = c + 1;
else if (butn1 == 7)
d = d + 1;
else if (butn1 == 8)
q = q + 1;
button1.Text = (butn1).ToString();
int butn2 = sayi.Next(1, 9);
if (butn2 == 1)
x = x + 1;
else if (butn2 == 2)
y = y + 1;
else if (butn2 == 3)
z = z + 1;
else if (butn2 == 4)
a = a + 1;
else if (butn2 == 5)
b = b + 1;
else if (butn2 == 6)
c = c + 1;
else if (butn2 == 7)
d = d + 1;
else if (butn2 == 8)
q = q + 1;
button2.Text = (butn2).ToString();
int butn3 = sayi.Next(1, 9);
if (butn3 == 1)
x = x + 1;
else if (butn3 == 2)
y = y + 1;
else if (butn3 == 3)
z = z + 1;
else if (butn3 == 4)
a = a + 1;
else if (butn3 == 5)
b = b + 1;
else if (butn3 == 6)
c = c + 1;
else if (butn3 == 7)
d = d + 1;
else if (butn3 == 8)
q = q + 1;
button3.Text = (butn3).ToString();
int butn4 = sayi.Next(1, 9);
if (butn4 == 1)
x = x + 1;
else if (butn4 == 2)
y = y + 1;
else if (butn4 == 3)
z = z + 1;
else if (butn4 == 4)
a = a + 1;
else if (butn4 == 5)
b = b + 1;
else if (butn4 == 6)
c = c + 1;
else if (butn4 == 7)
d = d + 1;
else if (butn4 == 8)
q = q + 1;
button4.Text = (butn4).ToString();
int butn5 = sayi.Next(1, 9);
if (butn5 == 1)
x = x + 1;
else if (butn5 == 2)
y = y + 1;
else if (butn5 == 3)
z = z + 1;
else if (butn5 == 4)
a = a + 1;
else if (butn5 == 5)
b = b + 1;
else if (butn5 == 6)
c = c + 1;
else if (butn5 == 7)
d = d + 1;
else if (butn5 == 8)
q = q + 1;
button5.Text = (butn5).ToString();
int butn6 = sayi.Next(1, 9);
if (butn6 == 1)
x = x + 1;
else if (butn6 == 2)
y = y + 1;
else if (butn6 == 3)
z = z + 1;
else if (butn6 == 4)
a = a + 1;
else if (butn6 == 5)
b = b + 1;
else if (butn6 == 6)
c = c + 1;
else if (butn6 == 7)
d = d + 1;
else if (butn6 == 8)
q = q + 1;
button6.Text = (butn6).ToString();
int butn7 = sayi.Next(1, 9);
if (butn7 == 1)
x = x + 1;
else if (butn7 == 2)
y = y + 1;
else if (butn7 == 3)
z = z + 1;
else if (butn7 == 4)
a = a + 1;
else if (butn7 == 5)
b = b + 1;
else if (butn7 == 6)
c = c + 1;
else if (butn7 == 7)
d = d + 1;
else if (butn7 == 8)
q = q + 1;
button7.Text = (butn7).ToString();
int butn8 = sayi.Next(1, 9);
if (butn8 == 1)
x = x + 1;
else if (butn8 == 2)
y = y + 1;
else if (butn8 == 3)
z = z + 1;
else if (butn8 == 4)
a = a + 1;
else if (butn8 == 5)
b = b + 1;
else if (butn8 == 6)
c = c + 1;
else if (butn8 == 7)
d = d + 1;
else if (butn8 == 8)
q = q + 1;
button8.Text = (butn8).ToString();
int butn9 = sayi.Next(1, 9);
if (butn9 == 1)
x = x + 1;
else if (butn9 == 2)
y = y + 1;
else if (butn9 == 3)
z = z + 1;
else if (butn9 == 4)
a = a + 1;
else if (butn9 == 5)
b = b + 1;
else if (butn9 == 6)
c = c + 1;
else if (butn9 == 7)
d = d + 1;
else if (butn9 == 8)
q = q + 1;
button9.Text = (butn9).ToString();
int butn10 = sayi.Next(1, 9);
if (butn10 == 1)
x = x + 1;
else if (butn10 == 2)
y = y + 1;
else if (butn10== 3)
z = z + 1;
else if (butn10== 4)
a = a + 1;
else if (butn10== 5)
b = b + 1;
else if (butn10 == 6)
c = c + 1;
else if (butn10== 7)
d = d + 1;
else if (butn10== 8)
q = q + 1;
button10.Text = (butn10).ToString();
int butn11 = sayi.Next(1, 9);
if (butn11 == 1)
x = x + 1;
else if (butn11 == 2)
y = y + 1;
else if (butn11 == 3)
z = z + 1;
else if (butn11 == 4)
a = a + 1;
else if (butn11 == 5)
b = b + 1;
else if (butn11 == 6)
c = c + 1;
else if (butn11 == 7)
d = d + 1;
else if (butn11 == 8)
q = q + 1;
button11.Text = (butn11).ToString();
int butn12 = sayi.Next(1, 9);
if (butn12 == 1)
x = x + 1;
else if (butn12 == 2)
y = y + 1;
else if (butn12 == 3)
z = z + 1;
else if (butn12 == 4)
a = a + 1;
else if (butn12 == 5)
b = b + 1;
else if (butn12 == 6)
c = c + 1;
else if (butn12 == 7)
d = d + 1;
else if (butn12 == 8)
q = q + 1;
button12.Text = (butn12).ToString();
int butn13 = sayi.Next(1, 9);
if (butn13 == 1)
x = x + 1;
else if (butn13 == 2)
y = y + 1;
else if (butn13 == 3)
z = z + 1;
else if (butn13 == 4)
a = a + 1;
else if (butn13 == 5)
b = b + 1;
else if (butn13 == 6)
c = c + 1;
else if (butn13 == 7)
d = d + 1;
else if (butn13 == 8)
q = q + 1;
button13.Text = (butn13).ToString();
int butn14 = sayi.Next(1, 9);
if (butn14 == 1)
x = x + 1;
else if (butn14 == 2)
y = y + 1;
else if (butn14 == 3)
z = z + 1;
else if (butn14 == 4)
a = a + 1;
else if (butn14 == 5)
b = b + 1;
else if (butn14 == 6)
c = c + 1;
else if (butn14 == 7)
d = d + 1;
else if (butn14 == 8)
q = q + 1;
button14.Text = (butn14).ToString();
int butn15 = sayi.Next(1, 9);
if (butn15 == 1)
x = x + 1;
else if (butn15 == 2)
y = y + 1;
else if (butn15 == 3)
z = z + 1;
else if (butn15 == 4)
a = a + 1;
else if (butn15 == 5)
b = b + 1;
else if (butn15 == 6)
c = c + 1;
else if (butn15 == 7)
d = d + 1;
else if (butn15 == 8)
q = q + 1;
button15.Text = (butn15).ToString();
int butn16 = sayi.Next(1, 9);
if (butn16 == 1)
x = x + 1;
else if (butn16 == 2)
y = y + 1;
else if (butn16 == 3)
z = z + 1;
else if (butn16 == 4)
a = a + 1;
else if (butn16 == 5)
b = b + 1;
else if (butn16 == 6)
c = c + 1;
else if (butn16 == 7)
d = d + 1;
else if (butn16 == 8)
q = q + 1;
button16.Text = (butn16).ToString();
}


Bu mesaja 1 cevap geldi.
G
9 yıl
Yarbay

sol üste iki tane yanyana label ekle label1 puan yazsın label2 boş olsun daha da geliştirilebilir

 
using System;
using System.Drawing;
using System.Windows.Forms;

namespace hatırla
{

public partial class MainForm : Form
{
public MainForm()
{

InitializeComponent();
Width=800;
Height=600;
}
Button[] buttonArray = new Button[81];
Random sayi = new Random();
int i;
public void oluştur()
{

int horizotal = 50;
int vertical = 50;

for (i = 0; i < buttonArray.Length; i++)
{
buttonArray[i] = new Button();
buttonArray[i].Tag=sayi.Next(1,9)+","+i;
buttonArray[i].Location = new Point(vertical, horizotal);
if ((i == 8) || (i == 17) || (i == 26) || (i == 35) || (i == 44) ||
(i == 53) || (i == 62) || (i == 71))
{
vertical = 50;
horizotal = horizotal + 50;
}
else
vertical = vertical + 80;
Controls.Add(buttonArray[i]);
//buttonArray[i].Text=buttonArray[i].Tag.ToString().Substring(0,1);
buttonArray[i].Click += (ClickButton);

}

}

int sayaç;
Button btn;
string değer;
int a;
public void ClickButton(Object sender, EventArgs e)
{
btn = sender as Button;

if (btn.Tag.ToString().Split(',').GetValue(0).ToString()==değer & a.ToString()!=btn.Tag.ToString().Split(',').GetValue(1).ToString()) {
sayaç++;
btn.Enabled=false;
btn.BackColor=Color.Green;
buttonArray[a].BackColor=Color.Green;
buttonArray[a].Enabled=false;
btn.Text=değer;
buttonArray[a].Text=değer;
}
a = Convert.ToInt32(btn.Tag.ToString().Split(',').GetValue(1).ToString());
değer=btn.Tag.ToString().Split(',').GetValue(0).ToString();
label2.Text=sayaç.ToString();

}
void MainFormLoad(object sender, EventArgs e)
{
oluştur();
}




}
}






< Bu mesaj bu kişi tarafından değiştirildi Gökşen PASLI -- 5 Aralık 2015; 18:22:40 >

DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.