示例#1
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Blue;
            //Console.BackgroundColor = ConsoleColor.White;
            //Console.Clear();

            Console.WriteLine("\n------------ Welcome to Home Cinema! -------------");

            var widescreenTv = new WidescreenTv();
            var dvdPlayer    = new DvdPlayer();
            var avReceiver   = new AvReceiver();

            var homeCinema = new HomeCinema(widescreenTv, dvdPlayer, avReceiver);

            bool alive = true;

            while (alive)
            {
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("\n---------------- Choose TV Mode ------------------");
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.WriteLine("\n1. Standard\t2. Cinema\t3. Сlassical Music\n4. Sport\t5. Custom\t6. Close Game");
                Console.ForegroundColor = ConsoleColor.Black;

                try
                {
                    Console.Write("Choose What to Do: ");
                    int command = Convert.ToInt32(Console.ReadLine());
                    switch (command)
                    {
                    case 1:
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                        Console.WriteLine("\n------ Standard Mode ------");
                        Console.ForegroundColor = ConsoleColor.Black;
                        homeCinema.SetStandard();
                        break;

                    case 2:
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                        Console.WriteLine("\n-------- Cinema Mode --------");
                        Console.ForegroundColor = ConsoleColor.Black;
                        homeCinema.SetCinema();
                        break;

                    case 3:
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                        Console.WriteLine("\n-- Сlassical Music Mode --");
                        Console.ForegroundColor = ConsoleColor.Black;
                        homeCinema.SetСlassicalMusic();
                        break;

                    case 4:
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                        Console.WriteLine("\n-------- Sport Mode --------");
                        Console.ForegroundColor = ConsoleColor.Black;
                        homeCinema.SetSport();
                        break;

                    case 5:
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                        Console.WriteLine("\n------- Custom Mode -------");
                        CustomMode customMode = new CustomMode();
                        Console.ForegroundColor = ConsoleColor.Black;
                        customMode.Custom(homeCinema);
                        break;

                    case 6:
                        alive = false;
                        Environment.Exit(0);
                        break;

                    default:
                        throw new Exception("No such command was found!");
                    }
                }
                catch (Exception ex)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine(ex.Message);
                }
            }

            Console.ReadKey();
        }
示例#2
0
        public void Custom(HomeCinema homeCinema)
        {
            Console.Write("Enter Brightness: ");
            int brightness = Convert.ToInt32(Console.ReadLine());

            if (brightness <= 0 || brightness > 100)
            {
                throw new Exception("Illegal brightness level!");
            }

            Console.Write("Enter Contrast: ");
            int contrast = Convert.ToInt32(Console.ReadLine());

            if (contrast <= 0 || contrast > 100)
            {
                throw new Exception("Illegal contrast level!");
            }

            Console.Write("Enter Volume: ");
            int volume = Convert.ToInt32(Console.ReadLine());

            if (volume <= 0 || volume > 100)
            {
                throw new Exception("Illegal volume level!");
            }

            Console.Write("Enter Speed: ");
            double speed = Convert.ToDouble(Console.ReadLine());

            if (speed <= 0 || speed > 3)
            {
                throw new Exception("Illegal speed level!");
            }

            Console.WriteLine("Enter Aspect Ratio");
            Console.Write("Enter Width: ");
            int width = Convert.ToInt32(Console.ReadLine());

            if (width <= 0 || width > 21)
            {
                throw new Exception("Illegal width!");
            }
            Console.Write("Enter Height: ");
            int height = Convert.ToInt32(Console.ReadLine());

            if (height <= 0 || height > 9)
            {
                throw new Exception("Illegal height!");
            }

            Console.WriteLine("Switch on Stereo?");
            Console.Write("1 - for YES, 2 - for NO: ");
            int stereo = Convert.ToInt32(Console.ReadLine());

            if (stereo < 1 || stereo > 2)
            {
                throw new Exception("No such command was found!");
            }

            homeCinema.SetCustom(brightness, contrast, width, height, speed, volume, stereo);
        }