151 lines
3.6 KiB
C#
151 lines
3.6 KiB
C#
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();
|
|
}
|
|
|
|
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<char> charList)
|
|
{
|
|
foreach (char x in charList)
|
|
{
|
|
if (x == c)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static bool Samelist(List<char> a, List<char> 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 void labelTextChange()
|
|
{
|
|
char[] text = new char[Data.word.Count()];
|
|
|
|
for (int i = 0; i < Data.word.Count(); i++)
|
|
{
|
|
for (int j = 0; j < Data.charfound.Count(); j++)
|
|
{
|
|
if (Data.charfound[j] == Data.wordchar[i])
|
|
{
|
|
text[i] = Data.charfound[j];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static class Data
|
|
{
|
|
//public static List<string> words = new List<string>();
|
|
public static string word = "alma";
|
|
public static List<char> wordchar = new List<char>();
|
|
public static List<char> charfound = new List<char>();
|
|
public static int hiba = 0;
|
|
}
|
|
}
|