Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApplication7
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19. string LiczbaPierwsza, LiczbaDruga;
  20. char RodzajDzialania = ' ';
  21. private void bDodawanie_Click(object sender, EventArgs e)
  22. {
  23. RodzajDzialania = '+';
  24. tbWynik.Text = "";
  25. }
  26.  
  27. private void bOdejmowanie_Click(object sender, EventArgs e)
  28. {
  29. RodzajDzialania = '-';
  30. tbWynik.Text = "";
  31. }
  32.  
  33. private void bMnozenie_Click(object sender, EventArgs e)
  34. {
  35. RodzajDzialania = '*';
  36. tbWynik.Text = "";
  37. }
  38.  
  39. private void bDzielenie_Click(object sender, EventArgs e)
  40. {
  41. RodzajDzialania = '/';
  42. tbWynik.Text = "";
  43. }
  44.  
  45. private void b0_Click(object sender, EventArgs e)
  46. {
  47. Dzialanie(0);
  48. }
  49.  
  50. private void b1_Click(object sender, EventArgs e)
  51. {
  52. Dzialanie(1);
  53. }
  54.  
  55. private void b2_Click(object sender, EventArgs e)
  56. {
  57. Dzialanie(2);
  58. }
  59.  
  60. private void b3_Click(object sender, EventArgs e)
  61. {
  62. Dzialanie(3);
  63. }
  64.  
  65. private void b4_Click(object sender, EventArgs e)
  66. {
  67. Dzialanie(4);
  68. }
  69.  
  70. private void b5_Click(object sender, EventArgs e)
  71. {
  72. Dzialanie(5);
  73. }
  74.  
  75. private void b6_Click(object sender, EventArgs e)
  76. {
  77. Dzialanie(6);
  78. }
  79.  
  80. private void b7_Click(object sender, EventArgs e)
  81. {
  82. Dzialanie(7);
  83. }
  84.  
  85. private void b8_Click(object sender, EventArgs e)
  86. {
  87. Dzialanie(8);
  88. }
  89.  
  90. private void b9_Click(object sender, EventArgs e)
  91. {
  92. Dzialanie(9);
  93. }
  94.  
  95. private void bWynik_Click(object sender, EventArgs e)
  96. {
  97. switch (RodzajDzialania)
  98. {
  99. case ('+'): tbWynik.Text = (int.Parse(LiczbaPierwsza) + int.Parse(LiczbaDruga)).ToString();
  100. break;
  101. case ('-'): tbWynik.Text = (int.Parse(LiczbaPierwsza) - int.Parse(LiczbaDruga)).ToString();
  102. break;
  103. case ('*'): tbWynik.Text = (int.Parse(LiczbaPierwsza) * int.Parse(LiczbaDruga)).ToString();
  104. break;
  105. case ('/'): tbWynik.Text = (int.Parse(LiczbaPierwsza) / int.Parse(LiczbaDruga)).ToString();
  106. break;
  107. }
  108. LiczbaPierwsza = "";
  109. LiczbaDruga = "";
  110. RodzajDzialania = ' ';
  111. }
  112. private void Dzialanie(int liczba)
  113. {
  114. if (RodzajDzialania == ' ')
  115. {
  116. LiczbaPierwsza += liczba;
  117. tbWynik.Text = LiczbaPierwsza;
  118. }
  119. else
  120. {
  121. LiczbaDruga += liczba;
  122. tbWynik.Text = LiczbaDruga;
  123. }
  124. }
  125. }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement