aboutsummaryrefslogtreecommitdiff
path: root/Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs
diff options
context:
space:
mode:
authorlempamo <[email protected]>2017-08-24 10:53:32 -0400
committerlempamo <[email protected]>2017-08-24 10:53:32 -0400
commit24ccb6a3350ee9a3ed8abea8e6f3eb6fbf45cf7f (patch)
tree79db295b73890523d29518ad1456e3fb3b07d2c2 /Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs
parente88b2da2e398f78cc56728ab7ef53ef590f536dd (diff)
downloadhistacom2-24ccb6a3350ee9a3ed8abea8e6f3eb6fbf45cf7f.tar.gz
histacom2-24ccb6a3350ee9a3ed8abea8e6f3eb6fbf45cf7f.tar.bz2
histacom2-24ccb6a3350ee9a3ed8abea8e6f3eb6fbf45cf7f.zip
completed guess the number and other things
Diffstat (limited to 'Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs')
-rw-r--r--Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs36
1 files changed, 36 insertions, 0 deletions
diff --git a/Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs b/Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs
index 31bc5cd..72adc0e 100644
--- a/Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs
+++ b/Histacom2/OS/Win95/Win95Apps/GuessTheNumber.cs
@@ -12,9 +12,45 @@ namespace Histacom2.OS.Win95.Win95Apps
{
public partial class GuessTheNumber : UserControl
{
+ private Random rnd;
+ private int num;
+
public GuessTheNumber()
{
InitializeComponent();
+
+ rnd = new Random();
+ num = rnd.Next(0, 101);
+
+ pictureBox1.MouseDown += (s, a) => pictureBox1.BackgroundImage = Properties.Resources.GTN95_CheckClicked;
+ pictureBox1.MouseUp += (s, a) => pictureBox1.BackgroundImage = Properties.Resources.GTN95_Check;
+ pictureBox3.MouseDown += (s, a) => pictureBox3.BackgroundImage = Properties.Resources.GTN95_RestartClicked;
+ pictureBox3.MouseUp += (s, a) => pictureBox3.BackgroundImage = Properties.Resources.GTN95_Restart;
+ }
+
+ private void pictureBox3_Click(object sender, EventArgs e)
+ {
+ pictureBox2.BackgroundImage = null;
+ textBox1.Enabled = true;
+ num = rnd.Next(0, 101);
+ }
+
+ private void pictureBox1_Click(object sender, EventArgs e)
+ {
+ try {
+ int guess = int.Parse(textBox1.Text);
+
+ if (guess < num) pictureBox2.BackgroundImage = Properties.Resources.GTN95_Higher;
+ else if (guess > num) pictureBox2.BackgroundImage = Properties.Resources.GTN95_Lower;
+ else if (guess == num)
+ {
+ pictureBox2.BackgroundImage = Properties.Resources.GTN95_Correct;
+ textBox1.Enabled = false;
+ }
+ } catch
+ {
+ pictureBox2.BackgroundImage = Properties.Resources.GTN95_Error;
+ }
}
}
}