Exemple #1
0
        static void Main(string[] args)
        {
            int      numberOfPints = 10;
            PintDish pintDish      = new PintDish(numberOfPints);

            pintDish.PintStarted   += PintDish_PintStarted;
            pintDish.PintCompleted += PintDish_PintCompleted;

            pintDish.Dishhalfway   += PintDish_DishHalfWay;
            pintDish.DishCompleted += PintDish_DishCompleted;

            for (int i = 0; i < numberOfPints; i++)
            {
                try
                {
                    pintDish.AddPint();
                    Console.WriteLine($"Pint {pintDish.PintCount} added\n\n");
                } catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            Console.ReadKey();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            pintDish = new PintDish(numberOfPints);

            try
            {
                pintDish.AddPint();
            }
            catch (Exception ex)
            {
                btnPintPlease.IsEnabled = false;
                MessageBox.Show(ex.Message);
                pintDish.timer.Stop();
            }

            pintDish.PintStarted   += PintDish_PintStarted;
            pintDish.DishCompleted += PintDish_DishCompleted;
        }
Exemple #3
0
        public void Run()
        {
            int numberOfPints = 10;
            var pintDish      = new PintDish(numberOfPints);

            for (int i = 0; i < numberOfPints; i++)
            {
                try
                {
                    pintDish.AddPint();
                    Console.WriteLine($"Pint {pintDish.PintCount} added to dish");
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.Message);
                }
            }

            Console.ReadLine();
        }
Exemple #4
0
        private void btnPintPlease_Click(object sender, RoutedEventArgs e)
        {
            PintDish pintDish = new PintDish(numberOfPints);

            pintDish.PintStarted   += PintDish_PintStarted;
            pintDish.PintCompleted += PintDish_PintCompleted;
            pintDish.DishCompleted += PintDish_DishCompleted;



            for (teller = 0; teller < numberOfPints; teller++)
            {
                try
                {
                    pintDish.AddPint();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }