Mario Code
Mario Code
cs
Form1.cs
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 MarioCalc
12 {
13 public partial class Form1 : Form
14 {
15 Double resultValue = 0;
16 String operationPerformed = "";
17 bool isOperationPerformed = false;
18 public Form1()
19 {
20 InitializeComponent();
21 }
22
23 private void button_click(object sender, EventArgs e)
24 {
25 if ((textBox_Result.Text == "0") || (isOperationPerformed))
26 textBox_Result.Clear();
27
28 isOperationPerformed = false;
29 Button button = (Button)sender;
30 if (button.Text == ".")
31 {
32 if (!textBox_Result.Text.Contains("."))
33 textBox_Result.Text = textBox_Result.Text + button.Text;
34
35 }
36 else
37 textBox_Result.Text = textBox_Result.Text + button.Text;
38 }
39
40 private void operator_click(object sender, EventArgs e)
41 {
42 Button button = (Button)sender;
43
44 if (resultValue != 0)
45 {
46 button15.PerformClick();
47 operationPerformed = button.Text;
48 labelCurrentOperation.Text = resultValue + " " + operationPerformed;
49 isOperationPerformed = true;
50 }
51 else
52 {
53
localhost:51293/a824afe3-0e2a-4e22-b6cc-389328f97a37/ 1/2
3/3/24, 11:28 PM Form1.cs
54 operationPerformed = button.Text;
55 resultValue = Double.Parse(textBox_Result.Text);
56 labelCurrentOperation.Text = resultValue + " " + operationPerformed;
57 isOperationPerformed = true;
58 }
59 }
60
61 private void Btn_CE_Click(object sender, EventArgs e)
62 {
63 textBox_Result.Text = "0";
64 }
65
66
67 private void Btn_eql(object sender, EventArgs e)
68 {
69 switch (operationPerformed)
70 {
71 case "+":
72 textBox_Result.Text = (resultValue +
Double.Parse(textBox_Result.Text)).ToString();
73 break;
74 case "-":
75 textBox_Result.Text = (resultValue -
Double.Parse(textBox_Result.Text)).ToString();
76 break;
77 case "*":
78 textBox_Result.Text = (resultValue *
Double.Parse(textBox_Result.Text)).ToString();
79 break;
80 case "/":
81 textBox_Result.Text = (resultValue /
Double.Parse(textBox_Result.Text)).ToString();
82 break;
83 default:
84 break;
85 }
86 resultValue = Double.Parse(textBox_Result.Text);
87 labelCurrentOperation.Text = "";
88 }
89
90 private void Btn_C_Click(object sender, EventArgs e)
91 {
92 textBox_Result.Text = "0";
93 resultValue = 0;
94 }
95 }
96 }
97
localhost:51293/a824afe3-0e2a-4e22-b6cc-389328f97a37/ 2/2