Ejemplo n.º 1
0
        static Magazine MagazineCreate()
        {
            Console.Clear();
            Console.Write("Insert Name of magazine: ");
            string a = Console.ReadLine();

            Console.WriteLine("Insert frequency release: ");
            FreqIndexes(false);
            int d = -1;

            while (!Int32.TryParse(Console.ReadLine(), out d) || d < 1 || d > 3)
            {
                Console.WriteLine("invalid input...\nInsert frequency release: ");
            }
            Frequency b = (Frequency)d;

            Console.WriteLine("Insert date release yyyy.mm.dd: ");
            string   tmps = Console.ReadLine();
            DateTime c    = new DateTime(Convert.ToInt32(tmps.Split('.')[0]), Convert.ToInt32(tmps.Split('.')[1]), Convert.ToInt32(tmps.Split('.')[2]));

            //тираж
            Console.Write("Insert routine: ");
            while (!Int32.TryParse(Console.ReadLine(), out d) || d < 1)
            {
                Console.WriteLine("Error...\nInsert circulation: ");
            }
            Magazine MyMagazine = new Magazine(a, b, c, d);

            Console.Write("Insert number of post: ");
            while (!Int32.TryParse(Console.ReadLine(), out d) || d < 1)
            {
                Console.Write("Error...\nInsert number of post: ");
            }
            Article[] tmp = new Article[d];
            for (int i = 0; i < d; i++)
            {
                Console.WriteLine("Post " + (i + 1));
                tmp[i] = ArticleCreate();
            }
            MyMagazine.AddArticles(tmp);
            return(MyMagazine);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            bool End = false;

            Magazine[] MagazineSet = new Magazine[0];
            while (true)
            {
                Console.Clear();
                MenuCreate(new string[] { "Add magazine ", "Brief info of magazine", "Value of indexer to see value of frequency", "Full info magazine", "Add post to magazine", "Compare time work with array", "exit" });
                switch (Console.ReadKey(true).Key)
                {
                // add magazine
                case ConsoleKey.D1:
                    Magazine[] tmp = new Magazine[MagazineSet.Length + 1];
                    for (int i = 0; i < MagazineSet.Length; i++)
                    {
                        tmp[i] = MagazineSet[i];
                    }
                    MagazineSet = tmp;
                    MagazineSet[MagazineSet.Length - 1] = MagazineCreate();
                    break;

                // brief info get
                case ConsoleKey.D2:
                    if (MagazineSet.Length > 0)
                    {
                        Console.WriteLine(MagazineSet[Chooser(MagazineSet)].ToShortString());
                    }
                    else
                    {
                        Console.Write("\nFirst Create magazine");
                    }
                    Console.ReadKey(true);
                    break;

                // just see all enums with index
                case ConsoleKey.D3:
                    FreqIndexes(true);
                    break;

                // full info of existing magazine
                case ConsoleKey.D4:
                    if (MagazineSet.Length > 0)
                    {
                        Console.WriteLine(MagazineSet[Chooser(MagazineSet)]);
                    }
                    else
                    {
                        Console.Write("\nFirst Create magazine");
                    }
                    Console.ReadKey(true);
                    break;

                // add article to magazine
                case ConsoleKey.D5:
                    if (MagazineSet.Length > 0)
                    {
                        MagazineSet[Chooser(MagazineSet)].AddArticles(ArticleAdd());
                    }
                    else
                    {
                        Console.Write("\nFirst Create magazine");
                    }
                    Console.ReadKey(true);
                    break;

                // doing test in arrays
                case ConsoleKey.D6:
                    SpeedTest();
                    break;

                // exit
                case ConsoleKey.D7:
                    End = true;
                    break;

                default: break;
                }
                if (End)
                {
                    break;
                }
            }
        }