// Sayi Tahmin Etme Oyunu | www.aliakyildirim.com | Ali AKYILDIRIM
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;
// Sayi Tahmin Etme Oyunu | www.aliakyildirim.com | Ali AKYILDIRIM
namespace SayiTahmini_Oyun
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Random rnd = new Random();
int a, b, c;
private void Form1_Load(object sender, EventArgs e)
{
txtSayi.Focus();
a = rnd.Next(0, 100);
b = 0;
c = 1000;
lblTahmin.Text = b.ToString();
lblPuan.Text = c.ToString();
}
private void btnKontrol_Click(object sender, EventArgs e)
{
try
{
int sayi;
sayi = int.Parse(txtSayi.Text);
lblSonRakam.Text = txtSayi.Text;
if (sayi == a)
{
lblDurum.ForeColor = Color.Green;
lblDurum.Text = "TEBRIKLER..!";
txtSayi.Enabled = false;
btnKontrol.Enabled = false;
b++;
lblTahmin.Text = b.ToString();
txtSayi.Focus();
}
else
{
if (sayi
{
lblDurum.ForeColor = Color.Brown;
lblDurum.Text = "YUKARI..!";
txtSayi.Focus();
}
if (sayi > a)
{
lblDurum.ForeColor = Color.Brown;
lblDurum.Text = "ASAGI..!";
txtSayi.Focus();
}
txtSayi.Clear();
b++;
c = c - 100;
lblTahmin.Text = b.ToString();
lblPuan.Text = c.ToString();
txtSayi.Focus();
if (c == 0)
{
lblDurum.ForeColor = Color.Red;
lblDurum.Text = "KAYBETTINIZ..!";
txtSayi.Enabled = false;
btnKontrol.Enabled = false;
txtSayi.Focus();
}
}
}
catch (Exception)
{
MessageBox.Show("Text Alanina Sayisal Bir Deger Girmediniz..!", "Bilgi:");
txtSayi.Focus();
}
}
private void btnYeni_Click(object sender, EventArgs e)
{
b = 0;
c = 1000;
txtSayi.Enabled = true;
btnKontrol.Enabled = true;
btnYeni.Enabled = false;
txtSayi.Clear();
lblDurum.Text = string.Empty;
lblTahmin.Text = b.ToString();
lblPuan.Text = c.ToString();
lblSonRakam.Text = string.Empty;
txtSayi.Focus();
}
}
}
// Sayi Tahmin Etme Oyunu | www.aliakyildirim.com | Ali AKYILDIRIM