Esempio n. 1
0
        static void Main(string[] args)
        {
            User   user   = new User();
            WorkPC workPC = new WorkPC();

            try
            {
                Menu.Start(user, workPC);
            }
            catch (DivideByZeroException e)
            {
                Design.Red();
                WriteLine("\n [err] " + e.Message);
            }
            catch (FormatException e)
            {
                Design.Red();
                WriteLine("\n [err] " + e.Message);
            }
            catch (DownloadMoreThanExistsException e)
            {
                Design.Red();
                WriteLine("\n [err] " + e.Message);
            }
            catch (Exception e)
            {
                Design.Red();
                WriteLine("\n [err] " + e.Message);
            }
            finally
            {
                Design.Default();
                WriteLine("\n >>> Завершение программы.\n");
            }
        }
Esempio n. 2
0
        public static void AddUserStorage(User user)
        {
            ConsoleKeyInfo SymbolKey;

            WriteLine(" Выберите тип носителя:");

            WriteLine(" 1 - Flash");
            WriteLine(" 2 - DVD");
            WriteLine(" 3 - HDD");

            Write("\n Ваш выбор: ");
            SymbolKey = ReadKey();
            WriteLine();
            Design.Line();

            switch (SymbolKey.Key)
            {
            case ConsoleKey.D1:
            case ConsoleKey.NumPad1:
                user.AddStorage(new Flash().Add());
                break;

            case ConsoleKey.D2:
            case ConsoleKey.NumPad2:
                user.AddStorage(new DVD().Add());
                break;

            case ConsoleKey.D3:
            case ConsoleKey.NumPad3:
                user.AddStorage(new HDD().Add());
                break;

            default:
                Design.Red();
                WriteLine("\n [err] Недопустимый тип носителя.");
                Design.Default();
                break;
            }
        }
Esempio n. 3
0
        public override Storage Add()
        {
            string   name;
            string   model;
            int      speedRead;
            int      speedRec;
            DiskType diskType;
            int      tempType;

            Write(" Введите название: ");
            name = ReadLine();
            Write(" Введите модель: ");
            model = ReadLine();
            Write(" Введите скорость (чтения): ");
            speedRead = Convert.ToInt32(ReadLine());
            Write(" Введите скорость (записи): ");
            speedRec = Convert.ToInt32(ReadLine());

            do
            {
                WriteLine(" Введите тип диска: ");
                WriteLine("  1 - 4,7 Gb\n  2 - 9,0 Gb");
                Write(" Тип: ");
                tempType = Convert.ToInt32(ReadLine());

                if (tempType < 1 || tempType > 2)
                {
                    Design.Red();
                    WriteLine("\n [err] Недопустимый тип диска." +
                              "\n - Повторите ввод!\n");
                    Design.Default();
                }
            } while (tempType < 1 || tempType > 2);

            diskType = (DiskType)tempType;

            return(new DVD(name, model, speedRead, speedRec, diskType));
        }