-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
76 lines (74 loc) · 2.23 KB
/
Form1.cs
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
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 _4Pics1Word
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void AddLetter(object sender, EventArgs e)
{
for(int i = 1; i <= 7; i++)
{
string butNum = "answer" + i;
if(this.Controls[butNum].Text == string.Empty)
{
this.Controls[butNum].Text = ((Button)sender).Text;
((Button)sender).Enabled = false;
this.Controls[butNum].Enabled = true;
break;
}
else
{
continue;
}
}
if(answer7.Text != string.Empty)
{
string answer = "CONSOLE";
string givenAnswer = string.Empty;
for(int i = 1; i <= 7; i++)
{
string butNum = "answer" + i;
givenAnswer += this.Controls[butNum].Text;
}
if(givenAnswer == answer)
{
MessageBox.Show(givenAnswer + " is the word. You win.");
this.Close();
}
else
{
MessageBox.Show(givenAnswer + " is not the word. Try again.");
}
}
}
private void ReturnLetter(object sender, EventArgs e)
{
for(int i = 1; i <= 10; i++)
{
string butNum = "letter" + i;
if(((Button)sender).Text == this.Controls[butNum].Text && this.Controls[butNum].Enabled == false)
{
((Button)sender).Text = string.Empty;
this.Controls[butNum].Enabled = true;
((Button)sender).Enabled = false;
break;
}
else
{
continue;
}
}
}
}
}