Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Form1 : Form
- {
- Double value = 0;
- String operation = "";
- bool operation_pressed = false;
- public Form1()
- {
- InitializeComponent();
- }
- private void button_click(object sender, EventArgs e)
- {
- {
- if ((wynik.Text == "0")|| (operation_pressed))
- {
- wynik.Clear();
- }
- Button b = (Button)sender;
- wynik.Text = wynik.Text + b.Text;
- }
- }
- private void ce_Click(object sender, EventArgs e)
- {
- wynik.Text = "0";
- }
- private void operator_click(object sender, EventArgs e)
- {
- Button b = (Button)sender;
- operation = b.Text;
- value = Double.Parse(wynik.Text);
- operation_pressed = true;
- label1.Text = value + " " + operation;
- }
- private void oblicz_Click(object sender, EventArgs e)
- {
- operation_pressed = false;
- NewMethod();
- }
- private void NewMethod()
- {
- label1.Text = "";
- switch (operation)
- {
- case "+":
- wynik.Text = (value + Double.Parse(wynik.Text)).ToString();
- break;
- case "-":
- wynik.Text = (value - Double.Parse(wynik.Text)).ToString();
- break;
- case "x":
- wynik.Text = (value * Double.Parse(wynik.Text)).ToString();
- break;
- case "/":
- wynik.Text = (value / Double.Parse(wynik.Text)).ToString();
- break;
- default: break;
- }
- }
- private void c_Click(object sender, EventArgs e)
- {
- wynik.Clear();
- value = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement