#
CLASS İÇİ #
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;
using System.Collections;
namespace WindowsFormsApplication9
{
class Class1
{
public int s = 0;
public int c = 0;
public ArrayList
say = new ArrayList();
public int i = 0;
public int puan=0;
public void rastgele(Form1 enes)
{
try
{
bool durum = true;
int m = 0;
while (durum)
{
Random ras = new
Random();
int a = ras.Next(1, 10);
int c = say.IndexOf(a);
if (c == -1)
{
say.Add(a);
m = say.Count;
}
if (m == 6)
{
durum = false;
}
}
}
catch
{
MessageBox.Show("Kodlarda hata var");
}
enes.button1.Text = say[0].ToString();
enes.button2.Text = say[1].ToString();
enes.button3.Text = say[2].ToString();
enes.button4.Text = say[3].ToString();
enes.button5.Text = say[4].ToString();
enes.button6.Text = say[5].ToString();
}
public void ikiz(Form1 bekir)
{
try
{
if (s == 2)
{
MessageBox.Show("Başka seçilemez...");
s = 0;
}
else
{
s += 1;
}
}
catch
{
MessageBox.Show("Kodlarda hata var");
}
}
public void topla(Form1 berk)
{
c
= c + Convert.ToInt32(say[i].ToString());
}
public void sonuc(Form1 mehtap)
{
if (c.ToString() == mehtap.textBox1.Text)
{
puan += 10;
mehtap.label3.Text = puan.ToString();
}
else
{
puan -= 5;
mehtap.label3.Text = puan.ToString();
}
}
}
}
#
BUTON İÇİ #
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 WindowsFormsApplication9
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Class1 selim = new
Class1();
private void
Form1_Load(object sender, EventArgs e)
{
selim.rastgele(this);
}
private void
tabPage2_Click(object sender, EventArgs e)
{
selim.rastgele(this);
}
private void button1_Click(object sender, EventArgs
e)
{
selim.ikiz(this);
if (selim.s != 0)
{
button1.Enabled = false;
selim.i = 0;
selim.topla(this);
}
}
private void
button2_Click(object sender, EventArgs e)
{
selim.ikiz(this);
if (selim.s != 0)
{
button2.Enabled = false;
selim.i = 1;
selim.topla(this);
}
}
private void
button4_Click(object sender, EventArgs e)
{
selim.ikiz(this);
if (selim.s != 0)
{
button4.Enabled = false;
selim.i = 3;
selim.topla(this);
}
}
private void
button5_Click(object sender, EventArgs e)
{
selim.ikiz(this);
if (selim.s != 0)
{
button5.Enabled = false;
selim.i = 4;
selim.topla(this);
}
}
private void
button6_Click(object sender, EventArgs e)
{
selim.ikiz(this);
if (selim.s != 0)
{
button6.Enabled = false;
selim.i = 5;
selim.topla(this);
}
}
private void
button3_Click(object sender, EventArgs e)
{
selim.ikiz(this);
if (selim.s != 0)
{
button3.Enabled = false;
selim.i = 2;
selim.topla(this);
}
}
private void
textBox1_KeyUp(object sender, KeyEventArgs e)
{
selim.sonuc(this);
}
}
}
Hiç yorum yok:
Yorum Gönder