Last active
October 4, 2016 17:49
-
-
Save dz0/572f5afa57ea2071b08affebf314bb75 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| using System.Windows; | |
| using System.Windows.Controls; | |
| using System.Windows.Data; | |
| using System.Windows.Documents; | |
| using System.Windows.Input; | |
| using System.Windows.Media; | |
| using System.Windows.Media.Imaging; | |
| using System.Windows.Navigation; | |
| using System.Windows.Shapes; | |
| namespace WpfApplication1_skaiciaus_spelione | |
| { | |
| /// <summary> | |
| /// Interaction logic for MainWindow.xaml | |
| /// </summary> | |
| public partial class MainWindow : Window | |
| { | |
| int tikslas; | |
| public MainWindow() | |
| { | |
| InitializeComponent(); | |
| Random rnd = new Random(); | |
| tikslas = rnd.Next(1, 10); // sugeneruojam atsitiktini tiksla | |
| } | |
| /// <summary> | |
| /// Reaguoja i ivesta spejima | |
| /// </summary> | |
| private void button_Click(object sender, RoutedEventArgs e) | |
| { | |
| //textBlock.Text = textBox.Text + "\n" + textBlock.Text; | |
| int spejimas = Convert.ToInt32(textBox.Text); | |
| // reiks ivertinti spejima: | |
| if (spejimas > tikslas) textBlock.Text = textBox.Text + "per daug" + "\n" + textBlock.Text; | |
| if (spejimas < tikslas) textBlock.Text = textBox.Text + "per mazai" + "\n" + textBlock.Text; | |
| if (spejimas == tikslas) | |
| { | |
| textBlock.Text += "\n" + "VALIO - atspejai!"; | |
| button.IsEnabled = false; // spejimu nebeleidziame | |
| button1.IsEnabled = true; // generuot tiksla leidziame | |
| } | |
| // Console.WriteLine("Valio - atspejai!"); | |
| } | |
| /// <summary> | |
| /// Sugeneruoja nauja tiksla ir leidzia zaist is naujo | |
| /// </summary> | |
| private void button1_Click(object sender, RoutedEventArgs e) | |
| { | |
| int riba = Convert.ToInt32(textBox1.Text); | |
| Random rnd = new Random(); | |
| tikslas = rnd.Next(1, riba); | |
| button.IsEnabled = true; // spejimus leidziame | |
| button1.IsEnabled = false; // generuot tikslo kol kas neleidziame | |
| textBlock.Text = "Paspeliokime is naujo:"; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment