Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                Gym gym = new Gym();
                gym.Add(new Tennis());
                gym.Add(new Basketball());
                //gym.Remove(4); //index  1


                СontrollerGym contr_gym = new СontrollerGym(1000);
                contr_gym.Add(new Shells(50));
                //contr_gym.Add(new Shells(40)); //budget 2


                Shells sh = new Shells(32);
                //sh.Amount = 2000; //max 3


                Gym gym2 = null;
                //gym2.Add(new Beams(1));
                Debug.Assert(gym2 != null, "Ссылка на объект не указывает на экземпляр объекта");


                int b, a = 2, c = 0;
                //b = a / c;
            }

            catch (IndexException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (BudgetException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (MaxException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.WriteLine("Переход к finally.");
            }

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Tennis ten = new Tennis();

            ten.ChooseRocket(Tennis.enumRocket.x);

            Gym gym = new Gym();

            Playground[] arrPlaygrounds = { new Tennis(), new Basketball(), new Beams(10), new Bench(), new Mats() };
            foreach (var i in arrPlaygrounds)
            {
                gym.Add(i);
            }
            gym.Show();
            gym.Remove(2);
            gym.Remove(6);///f
            gym.Show();



            /*________________________________________________________*/

            СontrollerGym cg = new СontrollerGym(30000);///бюджет

            Console.WriteLine("Количество снарядов:   |   Цена (каждый 12 руб):");
            cg.Add(new Shells(100));
            cg.Add(new Shells(90));
            cg.Add(new Shells(80));
            cg.Add(new Shells(166));
            cg.Add(new Shells(45));
            cg.Show();

            Console.WriteLine("_________________________________________________");
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("\nПосле сортировки:");
            Console.ResetColor();
            cg.Sort();
            cg.Show();

            Console.WriteLine("_________________________________________________");
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("\nВ диапазоне цены 500-1000:");
            Console.ResetColor();
            cg.СhoiceRange(500, 1000);
            cg.Show();



            Console.ReadLine();
        }