private void TestEvent3()
        {
            var    pb = new PigBank();
            var    bl = new BalanceLogger();
            var    bw = new BalanceWatcher(300m);
            string word;

            pb.BalanceChanged += bl.BalanceLog;
            pb.BalanceChanged += bw.BalanceWatch;

            do
            {
                Console.WriteLine("Inform your amount: ");
                word = Console.ReadLine();
                if (word == "exit")
                {
                    return;
                }

                if (decimal.TryParse(word, out decimal amount))
                {
                    pb.ChangeBalance(amount);
                }
                else
                {
                    Console.WriteLine("Not a valid amount!!");
                }
            } while (true);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var firstArg = string.Empty;

            if (args != null && args.Length > 0 && int.TryParse(args[0], out var algoritmNum))
            {
                switch (algoritmNum)
                {
                case 1:
                    RunMaxNearestNumberInArray();
                    break;

                case 2:
                    RunMatrixLayerRotation();
                    break;

                case 3:
                    var pigBank = new PigBank();
                    pigBank.Do();
                    break;

                case 4:
                    RunQuickSort();
                    break;

                case 5:
                    var sortedLinkedList = new SortedLinkedList();
                    sortedLinkedList.Do();
                    break;

                default:
                    Console.WriteLine("There are no algoritms for this number");
                    break;
                }
            }
            else
            {
                Console.WriteLine("Choose the algoritm you wanna to run (1 - MaxNearestNumberInArray, 2 - MatrixLayerRotation, 3 - PigBank, 4 - QuickSort)!");
            }

            Console.WriteLine("Press the key to end!");
            Console.ReadKey();
        }