931-21 guruh talabasi Madaminov Jayhunbek
10-Tajriba ishi
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public int a, b, operation;
public const int opAdd = 1; //эти константы будут определять
public const int opSub = 2; //типы операций
public const int opMul = 3;
public const int opDiv = 4;
public Form1()
{
InitializeComponent();
textBox2.Text = "0";
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button6_Click(object sender, EventArgs e)
{
if (textBox2.Text == "0" && textBox2.Text != null)
{
textBox2.Text = "6";
}
else
{
textBox2.Text = textBox2.Text + "6";
}
}
private void button9_Click(object sender, EventArgs e)
{
if (textBox2.Text == "0" && textBox2.Text != null)
{
textBox2.Text = "3";
}
else
{
textBox2.Text = textBox2.Text + "3";
}
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox2.Text == "0" && textBox2.Text != null)
{
textBox2.Text = "8";
}
else
{
textBox2.Text = textBox2.Text + "8";
}
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox2.Text == "0" && textBox2.Text != null)
{
textBox2.Text = "7";
}
else
{
textBox2.Text = textBox2.Text + "7";
}
}
private void button5_Click(object sender, EventArgs e)
{
if (textBox2.Text == "0" && textBox2.Text != null)
{
textBox2.Text = "9";
}
else
{
textBox2.Text = textBox2.Text + "9";
}
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox2.Text == "0" && textBox2.Text != null)
{
textBox2.Text = "4";
}
else
{
textBox2.Text = textBox2.Text + "4";
}
}
private void button4_Click(object sender, EventArgs e)
{
if (textBox2.Text == "0" && textBox2.Text != null)
{
textBox2.Text = "5";
}
else
{
textBox2.Text = textBox2.Text + "5";
}
}
private void button8_Click(object sender, EventArgs e)
{
if (textBox2.Text == "0" && textBox2.Text != null)
{
textBox2.Text = "1";
}
else
{
textBox2.Text = textBox2.Text + "1";
}
}
private void button7_Click(object sender, EventArgs e)
{
if (textBox2.Text == "0" && textBox2.Text != null)
{
textBox2.Text = "2";
}
else
{
textBox2.Text = textBox2.Text + "2";
}
}
private void button15_Click(object sender, EventArgs e)
{
if (textBox2.Text == "0" && textBox2.Text != null)
{
textBox2.Text = "0";
}
else
{
textBox2.Text = textBox2.Text + "0";
}
}
private void button11_Click(object sender, EventArgs e)
{
a = int.Parse(textBox2.Text);
textBox2.Clear();
textBox2.Focus();
operation = opAdd;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button12_Click(object sender, EventArgs e)
{
a = int.Parse(textBox2.Text);
textBox2.Clear();
textBox2.Focus();
operation = opAdd;
}
private void button14_Click(object sender, EventArgs e)
{
a = int.Parse(textBox2.Text);
textBox2.Clear();
textBox2.Focus();
operation = opAdd;
}
private void button13_Click(object sender, EventArgs e)
{
a = int.Parse(textBox2.Text);
textBox2.Clear();
textBox2.Focus();
operation = opAdd;
}
private void button10_Click(object sender, EventArgs e)
{
b = int.Parse(textBox2.Text);
switch (operation)
{
case opAdd:
{
int result = a + b; //выполняем сложение
textBox2.Text = result.ToString(); //выводим ответ в текстовое поле
//преобразуя в строковый тип т. к. свойство Text
//у текстового поля может принимать только строковые значения
break;
}
}
}
}
}
Dostları ilə paylaş: |