1-) C# - Sinema Class Ornek
class Sinema
{
int toplamKoltukSayisi;
int bosKoltukSayisi;
double bakiye;
string salonNo;
const double TAM = 15.0;
const double INDIRIMLI = 10.0;
public Sinema(string salonn, int koltuksayi)
{
toplamKoltukSayisi = koltuksayi;
salonNo = salonn;
bakiye = 0;
bosKoltukSayisi = toplamKoltukSayisi;
}
public void BiletSat(bool indirimli) //bilet satış metodu
{
bosKoltukSayisi--;
if (indirimli)
{
bakiye += INDIRIMLI;
}
else
{
bakiye += TAM;
}
}
public void BiletIptal(bool indirimli) //bilet iptal etme metotu
{
bosKoltukSayisi++;
if (indirimli)
{
bakiye -= INDIRIMLI;
}
else
{
bakiye -= TAM;
}
}
public double BakiyeOgren() //bakiye öğrenme metotu
{
return bakiye;
}
public int BoskoltukOgren()
{
return bosKoltukSayisi;
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Sinema salon;
private void button1_Click(object sender, EventArgs e)
{
salon = new Sinema(textBox1.Text, Convert.ToInt32(textBox2.Text));
label3.Text = "Salon Oluşturuldu. Koltuk sayısı : " + salon.BoskoltukOgren();
}
private void button2_Click(object sender, EventArgs e)
{
salon.BiletSat(checkBox1.Checked);
label3.Text = ("Bilet Satıldı. Kalan koltuk sayısı : ") + salon.BoskoltukOgren();
}
private void button3_Click(object sender, EventArgs e)
{
salon.BiletIptal(checkBox1.Checked);
label3.Text = "Bilet iptal edildi. Kalan Koltuk sayısı: " + salon.BoskoltukOgren();
}
private void button4_Click(object sender, EventArgs e)
{
label3.Text = "Şu anki bakiye: " + salon.BakiyeOgren() + "TL";
}
private void button5_Click(object sender, EventArgs e)
{
label3.Text = "Şu anki boş koltuk sayısı:" + salon.BoskoltukOgren();
}
}
}
