Sunteți pe pagina 1din 6

Universitatea Transilvania din Brașov

Facultatea de Inginerie Electrică și Știința Calculatoarelor


Departamentul Automatică și Tehnologia Informației

TEMĂ LABORATOR 02
POO

Chifor Andrei-Alexandru
Gr. 4LF491, AIA 2

BRAȘOV, 2021
Departamentul Automatică şi Tehnologia Informaţiei
Programul de studii Automatică şi Informatică Aplicată / Tehnologia Informației / Robotică
Portofoliu teme PCLP2

Cuprins

1. Tema L04.1 ............................................................................................................................................2


1.1. Enunț .............................................................................................................................................2
1.2. Rezolvare temă..............................................................................................................................2
1.3. Rezultate .......................................................................................................................................4

1
Departamentul Automatică şi Tehnologia Informaţiei
Programul de studii Automatică şi Informatică Aplicată / Tehnologia Informației / Robotică
Portofoliu teme PCLP2

1. Tema L04.1
Calculator Windows.

1.1. Enunț
Realizati un calculator pentru calcule matematice simple, asemanator cu cel din Windows.

1.2. Rezolvare temă


2. using System;
3. using System.Collections.Generic;
4. using System.ComponentModel;
5. using System.Data;
6. using System.Drawing;
7. using System.Linq;
8. using System.Text;
9. using System.Threading.Tasks;
10. using System.Windows.Forms;
11.
12. namespace Lab2_Poo
13. {
14. public partial class Form1 : Form
15. {
16. Double result = 0;
17. String operation = "";
18. bool preform_store = false;
19.
20. public Form1()
21. {
22. InitializeComponent();
23. }
24.
25. private void label1_Click(object sender, EventArgs e)
26. {
27.
28. }
29.
30. private void button2_Click(object sender, EventArgs e)
31. {
32. if (textBox1.Text == "0" || preform_store)
33. textBox1.Clear();
34.
35. preform_store = false;
36. Button button = (Button)sender;
37. if (button.Text == ".")
38. {
39. if(!textBox1.Text.Contains("."))
40. textBox1.Text = textBox1.Text + button.Text;
41. }
42. else
43. textBox1.Text = textBox1.Text + button.Text;
44. }
45.
46. private void operation_click(object sender, EventArgs e)
47. {
48. Button button = (Button)sender;
49. if (result != 0)
50. {
51. button18.PerformClick();
52. operation = button.Text;
2
Departamentul Automatică şi Tehnologia Informaţiei
Programul de studii Automatică şi Informatică Aplicată / Tehnologia Informației / Robotică
Portofoliu teme PCLP2

53. label1.Text = result + "" + operation;


54. preform_store = true;
55. }
56. else
57. {
58. operation = button.Text;
59. result = Double.Parse(textBox1.Text);
60. label1.Text = result + "" + operation;
61. preform_store = true;
62. }
63. }
64.
65. private void button16_Click(object sender, EventArgs e)
66. {
67. textBox1.Text = "0";
68. }
69.
70. private void button17_Click(object sender, EventArgs e)
71. {
72. textBox1.Text = "0";
73. result = 0;
74. }
75.
76. private void button18_Click(object sender, EventArgs e)
77. {
78. switch (operation)
79. {
80. case "+":
81. textBox1.Text = (result +
Double.Parse(textBox1.Text)).ToString();
82. break;
83. case "-":
84. textBox1.Text = (result -
Double.Parse(textBox1.Text)).ToString();
85. break;
86. case "*":
87. textBox1.Text = (result *
Double.Parse(textBox1.Text)).ToString();
88. break;
89. case "/":
90. textBox1.Text = (result /
Double.Parse(textBox1.Text)).ToString();
91. break;
92. default:
93. break;
94. }
95. result = Double.Parse(textBox1.Text);
96. label1.Text = "";
97. }
98. }
99. }

3
Departamentul Automatică şi Tehnologia Informaţiei
Programul de studii Automatică şi Informatică Aplicată / Tehnologia Informației / Robotică
Portofoliu teme PCLP2

1.3. Rezultate

4
Departamentul Automatică şi Tehnologia Informaţiei
Programul de studii Automatică şi Informatică Aplicată / Tehnologia Informației / Robotică
Portofoliu teme PCLP2

S-ar putea să vă placă și