-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
225 lines (212 loc) · 7.16 KB
/
Form1.cs
File metadata and controls
225 lines (212 loc) · 7.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
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 FastMath
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Int16 maxnum = 12;
public Int16 minutes = 1;
public Int16 minutes_timer = 1;
public Int16 seconds_timer = 59;
public Int16 ds_timer = 9;
public static int solved_ = 0;
public static List<String> operations = new List<string>();
public static bool graphenabled = false;
public static bool ingametimer = false;
public static bool rateofcalculations = false;
public static int rnd_num1 = 0;
public static int rnd_num2 = 0;
private void Form1_Load(object sender, EventArgs e)
{
}
public void GenerateRandom()
{
label3.Text = "";
Random r = new Random();
rnd_num1 = r.Next(1, maxnum);
rnd_num2 = r.Next(1, maxnum);
label3.Text = rnd_num1.ToString();
int rndoperation_index = r.Next(0, operations.ToArray().Length);
if(operations.ToArray()[rndoperation_index]=="addition")
{
label3.Text = label3.Text + " + ";
label3.Text = label3.Text + rnd_num2;
}
else if (operations.ToArray()[rndoperation_index] == "subtraction")
{
label3.Text = label3.Text + " - ";
if ((rnd_num1 - rnd_num2) < 0)
{
int temp_rndnum_ = rnd_num1;
rnd_num1 = rnd_num2;
rnd_num2 = temp_rndnum_;
}
label3.Text = rnd_num1 + " - " + rnd_num2;
}
else if (operations.ToArray()[rndoperation_index] == "multiplication")
{
label3.Text = label3.Text + " · ";
label3.Text = label3.Text + rnd_num2;
}
else if (operations.ToArray()[rndoperation_index] == "division")
{
label3.Text = label3.Text + " / ";
while(rnd_num1%rnd_num2!=0)
{
rnd_num2 = r.Next(1, maxnum);
}
label3.Text = label3.Text + rnd_num2;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (!checkBox1.Checked && !checkBox2.Checked && !checkBox3.Checked && !checkBox4.Checked)
{
MessageBox.Show("Please select at least one skill to practice!");
}
else
{
maxnum = Convert.ToInt16(numericUpDown2.Value);
minutes = Convert.ToInt16(numericUpDown1.Value);
minutes_timer = Convert.ToInt16(numericUpDown1.Value-1);
if (checkBox1.Checked)
{
operations.Add("addition");
}
if (checkBox2.Checked)
{
operations.Add("division");
}
if (checkBox3.Checked)
{
operations.Add("multiplication");
}
if (checkBox4.Checked)
{
operations.Add("subtraction");
}
if (checkBox5.Checked)
{
chart1.Visible = true;
label11.Visible = true;
}
if (!checkBox5.Checked)
{
chart1.Visible = false;
label11.Visible = false;
}
if (checkBox6.Checked)
{
label8.Visible = true;
}
if (!checkBox6.Checked)
{
label8.Visible = false;
}
if (checkBox7.Checked == true)
{
label10.Visible = true;
}
if (checkBox7.Checked == false)
{
label10.Visible = false;
}
panel1.Visible = false;
GenerateRandom();
timer1.Start();
this.AcceptButton = button2;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (minutes_timer == 0 && seconds_timer == 1 && ds_timer == 2)
{
panel3.Visible = false;
label9.Text = solved_.ToString() + " Correct";
double rate = (double)solved_ / (minutes * 60);
label10.Text = "Rate of calculations : " + Math.Round(rate, 1) + "/second";
chart1.Series[0].Points.AddY(solved_);
timer1.Stop();
}
ds_timer--;
if (ds_timer == 1)
{
ds_timer = 9;
seconds_timer--;
}
label8.Text = minutes_timer.ToString() + ":" + seconds_timer.ToString() + ":" + ds_timer.ToString();
if (seconds_timer == 1 && minutes_timer!=0)
{
seconds_timer = 59;
minutes_timer--;
}
}
private void button2_Click(object sender, EventArgs e)
{
if(label3.Text.Contains("+"))
{
if((rnd_num1+rnd_num2).ToString()==textBox1.Text)
{
solved_++;
GenerateRandom();
textBox1.Clear();
}
}
else if(label3.Text.Contains("-"))
{
if ((rnd_num1 - rnd_num2).ToString() == textBox1.Text)
{
solved_++;
GenerateRandom();
textBox1.Clear();
}
}
else if(label3.Text.Contains("·"))
{
if ((rnd_num1 * rnd_num2).ToString() == textBox1.Text)
{
solved_++;
GenerateRandom();
textBox1.Clear();
}
}
else if(label3.Text.Contains("/"))
{
if ((rnd_num1 / rnd_num2).ToString() == textBox1.Text)
{
solved_++;
GenerateRandom();
textBox1.Clear();
}
}
}
private void button3_Click(object sender, EventArgs e)
{
maxnum = 12;
minutes = 1;
minutes_timer = 1;
seconds_timer = 59;
ds_timer = 9;
solved_ = 0;
operations = new List<string>();
graphenabled = false;
ingametimer = false;
rateofcalculations = false;
rnd_num1 = 0;
rnd_num2 = 0;
panel3.Visible = true;
panel1.Visible = true;
}
}
}