Пример #1
0
        static void Main(string[] args)
        {
            try
            {
                CollectionType <string> obj1 = new CollectionType <string>();
                IGeneric <string>       a;
                obj1.Add("bye ");
                obj1.Add("adyos ");
                obj1.Add("sayonara ");
                a = obj1;
                a.Show();
                obj1.SaveInFile();

                Console.WriteLine();
                CollectionType <Playground> plGr = new CollectionType <Playground>();
                plGr.Add(new Basketball());
                plGr.Add(new Bench());
                plGr.Add(new Tennis());

                Playground beam = new Beams(12);
                plGr.Add(beam);
                plGr.Show();

                Console.WriteLine();
                plGr.Delete(beam);
                plGr.Show();
                plGr.SaveInFile();

                CollectionType <Playground> pl2 = new CollectionType <Playground>();
                LoadFromFile(ref pl2);
                Console.WriteLine("\nЭлементы файла file.txt:");
                pl2.Show();
            }

            catch (CollectionException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.WriteLine("\nFINALLY");
            }
            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            //Console.WriteLine("-----------Розы-------------");
            //Rose rose = new Rose();
            //rose.ToPlant();
            //rose.GetPlants();
            //rose.ToPlant();
            //rose.ToPlant();
            //rose.GetPlants();
            //rose.Pour(3);
            //if (rose is Plant)
            //{
            //    Console.WriteLine($"{rose} is plant");
            //}

            //Console.WriteLine("-----------Кактусы-------------");
            //Cactus cactus = new Cactus();
            //IPot cactus_2 = cactus;
            //cactus_2.ToPlant();
            //cactus.ToPlant();
            //cactus.GetPlants();
            //cactus.Collect();
            //cactus.PutInPot();

            //Console.WriteLine("-----------Гладиолусы-------------");
            //Gladiolus gladiolus = new Gladiolus();
            //gladiolus.ToPlant();
            //gladiolus.ToPlant();
            //gladiolus.Pour(2);
            //gladiolus.Collect();
            //gladiolus.PackIn();

            //Printer printer = new Printer();
            //printer.iAmPrinting(cactus);

            CollectionType <string> obj1 = new CollectionType <string>();
            IGereric <string>       a;

            obj1.Add("bye ");
            obj1.Add("adyos ");
            obj1.Add("sayonara ");
            a = obj1;
            a.Show();

            CollectionType <Plant> plnt = new CollectionType <Plant>();

            plnt.Add(new Rose());
            plnt.Add(new Gladiolus());
            plnt.Add(new Bush());
            plnt.Show();

            Console.WriteLine("\n");
            CollectionType <Plant> obj2 = new CollectionType <Plant>();

            ParseFile(obj2);
            obj2.Show();

            obj2.WriteFile(obj2);
        }