using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace bj2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Random random = new Random(); private bool geç = true; private int o1sayı; private int o2sayı; private void Form1_Load(object sender, EventArgs e) { button4.Visible = false; button5.Visible = false; button6.Visible = false; button7.Visible = false; o1sayı = random.Next(1,12); o2sayı = random.Next(1,12); label1.Text = o1sayı.ToString(); label2.Text = o2sayı.ToString(); } private void button2_Click(object sender, EventArgs e) { int randomer; randomer = random.Next(1,11); o1sayı = randomer + o1sayı; label1.Text = o1sayı.ToString(); if (o1sayı > 21) { button1.Visible = false; button2.Visible = false; button3.Visible = false; MessageBox.Show("Oyuncu 1 Patladı"); } } private void button5_Click(object sender, EventArgs e) { int randomer; randomer = random.Next(1, 11); o2sayı = randomer + o2sayı; label2.Text = o2sayı.ToString(); if(o2sayı > 21) { button6.Visible = false; button4.Visible = false; button5.Visible = false; } } private void button3_Click(object sender, EventArgs e) { button1.Visible = false; button2.Visible = false; button3.Visible = false; button4.Visible = true; button5.Visible = true; button6.Visible = true; button7.Visible = true; } private void button4_Click(object sender, EventArgs e) { button1.Visible = false; button2.Visible = false; button3.Visible = false; button4.Visible = false; button5.Visible = false; button6.Visible = false; } private void button7_Click(object sender, EventArgs e) { if(o1sayı > 21) { MessageBox.Show("Oyuncu 1 Patladı Oyuncu 2 Kazandı"); return; } else if(o2sayı > 21) { MessageBox.Show("Oyuncu 2 Patladı Oyuncu 1 Kazandı"); return; } if(o1sayı > o2sayı) { MessageBox.Show("Oyuncu 1 Kazandı"); return; } else { MessageBox.Show("Oyuncu 2 Kazandı"); } } } }