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 WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void pictureBox1_Click(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { //Data.words.Add("alma"); //Data.words.Add("számítógép"); for (int i = 0; i < Data.word.Count(); i++) { label1.Text += "-"; } WordToChars(Data.word); Data.wordchar.Sort(); } private void button1_Click(object sender, EventArgs e) { char guess = Convert.ToChar(textBox1.Text); if (Isin(guess, Data.word)) { if (CharNotInList(guess, Data.charfound)) { Data.charfound.Add(guess); Data.charfound.Sort(); label1.Text = labelTextChange(label1.Text); } if (Samelist(Data.charfound, Data.wordchar)) { MessageBox.Show("GRATULÁLOK!"); } } else { Data.hiba++; if (Data.hiba > 11) { MessageBox.Show("Sajnos vesztettél."); Data.hiba = 0; } pictureBox1.Image = Image.FromFile($@"images\{Data.hiba}.png"); } } public static bool Isin(char x, string word) { foreach (char c in word) { if (c == x) { return true; } } return false; } public static void WordToChars(string word) { foreach (char c in word) { if (CharNotInList(c, Data.wordchar)) { Data.wordchar.Add(c); } } } public static bool CharNotInList(char c, List charList) { foreach (char x in charList) { if (x == c) { return false; } } return true; } public static bool Samelist(List a, List b) { if (a.Count != b.Count) { return false; } for (int i = 0; i < a.Count; i++) { if (a[i] != b[i]) { return false; } } return true; } public static string labelTextChange(string temp) { return temp; } } public static class Data { //public static List words = new List(); public static string word = "alma"; public static List wordchar = new List(); public static List charfound = new List(); public static int hiba = 0; } }