using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Soutez { public partial class FormTrasa : Form { public bool chyba = false; public FormTrasa() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { short X = 0; short Y = 0; foreach (char ch in textBox1.Text) { if (ch == '<') X--; else if (ch == '>') X++; else if (ch == '^') Y++; else if (ch == 'V') Y--; else { chyba = true; } } if (chyba) { MessageBox.Show("Cesta obsahuje neplatné znaky a nebude uložena.", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (!chyba && (X != 0 || Y != 0)) { MessageBox.Show("Po dokončení trasy se musí zvěd vrátit na své místo!\nCesta nebude uložena.", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error); chyba = true; } } } }