Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Projekt_1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- string A = "";
- string B = "";
- int Aint;
- int Bint;
- string OPER;
- int licz = 0;
- private void button1_Click(object sender, EventArgs e)
- {
- if (licz == 0)
- {
- A += "1";
- textBox1.Text += "1";
- }
- else
- {
- B += "1";
- textBox1.Text += "1";
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (licz == 0)
- {
- A += "2";
- textBox1.Text += "2";
- }
- else
- {
- B += "2";
- textBox1.Text += "2";
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- if (licz == 0)
- {
- A += "3";
- textBox1.Text += "3";
- }
- else
- {
- B += "3";
- textBox1.Text += "3";
- }
- }
- private void button4_Click(object sender, EventArgs e)
- {
- if (licz == 0)
- {
- A += "4";
- textBox1.Text += "4";
- }
- else
- {
- B += "4";
- textBox1.Text += "4";
- }
- }
- private void button5_Click(object sender, EventArgs e)
- {
- if (licz == 0)
- {
- A += "5";
- textBox1.Text += "5";
- }
- else
- {
- B += "5";
- textBox1.Text += "5";
- }
- }
- private void button6_Click(object sender, EventArgs e)
- {
- if (licz == 0)
- {
- A += "6";
- textBox1.Text += "6";
- }
- else
- {
- B += "6";
- textBox1.Text += "6";
- }
- }
- private void button7_Click(object sender, EventArgs e)
- {
- if (licz == 0)
- {
- A += "7";
- textBox1.Text += "7";
- }
- else
- {
- B += "7";
- textBox1.Text += "7";
- }
- }
- private void button8_Click(object sender, EventArgs e)
- {
- if (licz == 0)
- {
- A += "8";
- textBox1.Text += "8";
- }
- else
- {
- B += "8";
- textBox1.Text += "8";
- }
- }
- private void button9_Click(object sender, EventArgs e)
- {
- if (licz == 0)
- {
- A += "9";
- textBox1.Text += "9";
- }
- else
- {
- B += "9";
- textBox1.Text += "9";
- }
- }
- private void button10_Click(object sender, EventArgs e)
- {
- if (licz == 0)
- {
- A += "0";
- textBox1.Text += "0";
- }
- else
- {
- B += "0";
- textBox1.Text += "0";
- }
- }
- private void button15_Click(object sender, EventArgs e)
- {
- Int32.TryParse(A, out Aint);
- Int32.TryParse(B, out Bint);
- if ( !String.IsNullOrEmpty(A) && !String.IsNullOrEmpty(B) && OPER != null)
- switch (OPER)
- {
- case "+":
- textBox1.Text += "=" + (Aint + Bint).ToString();
- break;
- case "-":
- textBox1.Text += "=" + (Aint - Bint).ToString();
- break;
- case "*":
- textBox1.Text += "=" + (Aint * Bint).ToString();
- break;
- case "^":
- textBox1.Text += "=" + Math.Pow(Aint,Bint).ToString();
- break;
- case "/":
- try
- {
- textBox1.Text += "=" + (Aint / Bint).ToString();
- }
- catch (Exception err)
- {
- MessageBox.Show("Nie dzielimy przez zero!", "Uwaga", MessageBoxButtons.OK);
- }
- finally
- {
- }
- break;
- }
- A = "";
- B = "";
- OPER = null;
- licz = 0;
- }
- private void button11_Click(object sender, EventArgs e)
- {
- if (OPER == null && !String.IsNullOrEmpty(A))
- {
- OPER += "+";
- textBox1.Text += "+";
- licz = 1;
- }
- }
- private void button12_Click(object sender, EventArgs e)
- {
- if (OPER == null && !String.IsNullOrEmpty(A))
- {
- OPER += "-";
- textBox1.Text += "-";
- licz = 1;
- }
- }
- private void button13_Click(object sender, EventArgs e)
- {
- if (OPER == null && !String.IsNullOrEmpty(A))
- {
- OPER += "*";
- textBox1.Text += "*";
- licz = 1;
- }
- }
- private void button14_Click(object sender, EventArgs e)
- {
- if (OPER == null && !String.IsNullOrEmpty(A))
- {
- OPER += "/";
- textBox1.Text += "/";
- licz = 1;
- }
- }
- private void button16_Click(object sender, EventArgs e)
- {
- if (OPER == null && !String.IsNullOrEmpty(A))
- {
- OPER += "^";
- textBox1.Text += "^";
- licz = 1;
- }
- }
- private void button17_Click(object sender, EventArgs e)
- {
- textBox1.Clear();
- A = "";
- B = "";
- OPER = null;
- licz = 0;
- Aint = 0;
- Bint = 0;
- }
- //private void check()
- //{
- // string slowo = "a+b=c";
- // string[] val = slowo.split("+".tochararray());
- // a = int32.parse(val[0]);
- // b = int32.parse(val[1].split("=".tochararray())[0]);
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement