Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.Write("Select the mode: ");
            string mode   = Console.ReadLine();
            Player player = new Player();

            switch (mode.ToLower())
            {
            case "record":
                Console.WriteLine("Available action in this mode:");
                IRecodable recodable = player as IRecodable;
                recodable.Record();
                recodable.Pause();
                recodable.Stop();
                break;

            case "play":
                Console.WriteLine("Available action in this mode:");
                IPlayable playable = player as IPlayable;
                playable.Play();
                playable.Pause();
                playable.Stop();
                break;

            default:
                Console.WriteLine("The mode is not exist.");
                break;
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Player     player = new Player();
            IRecodable ir     = player as IRecodable;

            ir.Record();
            Console.ReadLine();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Player     player    = new Player();
            IPlayable  playable  = player;
            IRecodable recodable = player as IRecodable;

            playable.Play();
            playable.Pause();
            recodable.Record();
        }
Esempio n. 4
0
        static void ActionsInPlayer()
        {
            Player player = new Player();

            Console.WriteLine("Выберите действие: 1 - воспроизвидение муз. 2 - запись звука");
            int action = int.Parse(Console.ReadLine());

            switch (action)
            {
            case 1:
                player.Play();

                Console.WriteLine("Следующее действие муз.устройства: 1 - Пауза; 2 - Остановить; 3 - Выход;");
                int       newAction = int.Parse(Console.ReadLine());
                IPlayable iPlayable = (IPlayable)player;
                switch (newAction)
                {
                case 1:
                    iPlayable.Pause();
                    break;

                case 2:
                    iPlayable.Stop();
                    break;

                case 3:
                    break;
                }
                break;

            case 2:
                player.Record();
                Console.WriteLine("Следующее действие записывающего устройства: 1 - Пауза; 2 - Остановить; 3 - Выход;");
                int        nextAction = int.Parse(Console.ReadLine());
                IRecodable iRecodable = (IRecodable)player;
                switch (nextAction)
                {
                case 1:
                    iRecodable.Pause();
                    break;

                case 2:
                    iRecodable.Stop();
                    break;

                case 3:
                    break;
                }
                break;

            default:
                Console.WriteLine("Ошибка выбора");
                break;
            }
        }
        /// <summary>
        /// Выполняет запись
        /// </summary>
        public static void Recording()
        {
            int action;

            do
            {
                IRecodable playerRecording = player;
                SpeakAndRecord(out action);
                SetRecordingActions(playerRecording, action);
            }while (action != 3);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Player player = new Player();

            player.Play();
            player.Stop();
            player.Record();
            player.Pause();
            IRecodable player2 = player;

            player2.Pause();
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            Player    player   = new Player();
            IPlayable playable = player as IPlayable;

            playable.play();
            playable.pause();
            playable.stop();
            Console.WriteLine("----------------------------------");
            IRecodable record = player as IRecodable;

            record.play();
            record.pause();
            record.stop();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Player pl = new Player();

            IPlayable  ipl = pl;
            IRecodable irc = pl;

            ipl.Play();
            irc.Record();

            Console.WriteLine(ipl.GetHashCode());
            Console.WriteLine(irc.GetHashCode());
            Console.WriteLine(pl.GetHashCode());
            Console.ReadKey();
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            Player     player    = new Player();
            IRecodable recodable = player as IRecodable;

            recodable.Record();
            recodable.Pause();
            recodable.Stop();
            Console.WriteLine(new string('-', 50));
            IPlayable playable = player as IPlayable;

            playable.Play();
            playable.Pause();
            playable.Stop();
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            IPlayable player = new Player();

            player.Play();
            player.Stop();
            player.Pause();
            Console.WriteLine(new string('*', 80));

            IRecodable player1 = player as IRecodable;

            player1.Record();
            player1.Pause();
            player1.Stop();
        }
Esempio n. 11
0
        private static void Main(string[] args)
        {
            Player    player     = new Player();
            IPlayable playPlayes = player;

            playPlayes.Play();
            playPlayes.Pause();
            playPlayes.Stop();

            IRecodable recordPlayes = player;

            recordPlayes.Record();
            recordPlayes.Pause();
            recordPlayes.Stop();

            Console.Read();
        }
Esempio n. 12
0
        /* Створіть 2 інтерфейсу IPlayable і IRecodable. У кожному з інтерфейсів створіть по 3 методу
         * voidPlay () / voidPause () / voidStop () і voidRecord () / voidPause () / voidStop () відповідно.
         * Створіть похідний клас Player від базових інтерфейсів IPlayable і IRecodable. Написати програму, яка виконує програвання і запис.*/

        static void Main(string[] args)
        {
            Player myPlay = new Player();

            IPlayable myPlayer = myPlay as IPlayable;

            myPlayer.Play();
            myPlayer.Pause();
            myPlayer.Stop();

            IRecodable myRecorder = myPlay as IRecodable;

            myRecorder.Record();
            myRecorder.Pause();
            myRecorder.Stop();

            Console.ReadKey();
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            Console.WriteLine("Work of the player");
            IPlayable player = new Player();

            player.Play();
            player.Pause();
            player.Stop();

            Console.WriteLine("Work of the recorder:");
            IRecodable recorder = (IRecodable)player;

            recorder.Record();
            recorder.Pause();
            recorder.Stop();

            Console.ReadKey();
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            Player player = new Player();

            IRecodable recodable = player as Player;

            player.Record();
            recodable.Stop();
            recodable.Pause();

            Console.WriteLine();

            player.Play();
            (player as IPlayable).Stop();
            (player as IPlayable).Pause();

            Console.ReadKey();
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            Player    player = new Player();
            IPlayable ip     = player as IPlayable;

            ip.Play();
            ip.Pause();
            ip.Stop();

            Console.WriteLine();

            IRecodable ir = player as IRecodable;

            ir.Record();
            ir.Pause();
            ir.Stop();

            Console.ReadLine();
        }
Esempio n. 16
0
            public static void Show(IRecodable player)
            {
                string answer = String.Empty;

                do
                {
                    Console.WriteLine("Выберите действие с записью:");
                    Console.WriteLine("0 - Выход");
                    Console.WriteLine("1 - Выполнить запись");
                    Console.WriteLine("2 - Приостановить запись");
                    Console.WriteLine("3 - Остановить запись");

                    answer = Console.ReadLine();
                    Console.WriteLine("\n");

                    switch (answer)
                    {
                    case "0":
                        Console.WriteLine("Выполняем выход...");
                        break;

                    case "1":
                        player.Record();
                        break;

                    case "2":
                        player.Pause();
                        break;

                    case "3":
                        player.Stop();
                        break;

                    default:
                        Console.WriteLine("Некорректное действие, попробуйте еще раз...");
                        break;
                    }
                    Console.WriteLine("\n");
                } while (answer != "0");
            }
        /// <summary>
        /// Установить действия плеера в режиме записи песен
        /// </summary>
        /// <param name="playerRecording"> Режим записи песен </param>
        /// <param name="action"> Действие </param>
        private static void SetRecordingActions(IRecodable playerRecording, int action)
        {
            switch (action)
            {
            case 1:
            {
                playerRecording.Record();
                break;
            }

            case 2:
            {
                playerRecording.Pause();
                break;
            }

            default:
            {
                playerRecording.Stop();
                break;
            }
            }
        }
Esempio n. 18
0
        public static void StartMenu(Player player)
        {
            do
            {
                Console.Clear();
                // First choice of user action
                byte firstChoice;
                Console.WriteLine((byte)FirstMenuItem.Play + ". Play");
                Console.WriteLine((byte)FirstMenuItem.Record + ". Record");
                Console.WriteLine((byte)FirstMenuItem.Exit + ". Exit");
                Console.WriteLine("Make your choice:");
                firstChoice = ReadChoice();
                Console.Clear();
                switch ((FirstMenuItem)firstChoice)
                {
                case FirstMenuItem.Play:     // User chooses Play
                    player.Play();
                    break;

                case FirstMenuItem.Record:     // User chooses Record
                    player.Record();
                    break;

                case FirstMenuItem.Exit:     // User chooses Exit
                    Environment.Exit(0);
                    break;

                default:     // User makes wrong choice
                    break;
                }

                Console.WriteLine((byte)SecondMenuItem.Pause + ". Pause");
                Console.WriteLine((byte)SecondMenuItem.Stop + ". Stop");
                Console.WriteLine((byte)SecondMenuItem.Exit + ". Exit");
                Console.WriteLine("Make your choice:");

                // Second user choice in case Playing
                byte secondChoice = ReadChoice();

                switch ((SecondMenuItem)secondChoice)
                {
                case SecondMenuItem.Pause:                                // User chooses Pause
                {
                    if ((FirstMenuItem)firstChoice == FirstMenuItem.Play) // Playing
                    {
                        IPlayable iPlayable = player;
                        iPlayable.Pause();
                    }
                    else         // Recording
                    {
                        IRecodable iRecodable = player;
                        iRecodable.Pause();
                    }
                    break;
                }

                case SecondMenuItem.Stop:                                 // User chooses Stop
                {
                    if ((FirstMenuItem)firstChoice == FirstMenuItem.Play) // Playing
                    {
                        IPlayable iPlayable = player;
                        iPlayable.Stop();
                    }
                    else
                    {
                        IRecodable iRecodable = player;          // Recording
                        iRecodable.Stop();
                    }
                    break;
                }

                case SecondMenuItem.Exit:     // User chooses Exit
                    Environment.Exit(0);
                    break;

                default:     // User makes wrong choice
                    break;
                }
                Console.ReadKey();
                Console.Clear();
            } while (true);
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            //1
            Console.Write("Enter number document: ");
            int number = Int32.Parse(Console.ReadLine());

            Console.Write("Document format\n" +
                          "XML - X\n" +
                          "TXT - T\n" +
                          "DOC - D\n");

            List <AbstractHandler> documents = new List <AbstractHandler>();

            for (int i = 0; i < number; i++)
            {
                Console.Write("Enter formant for {0} document: ", i + 1);
                string format = Console.ReadLine();

                if (format == "X")
                {
                    documents.Add(new XMLHandler());
                }
                else if (format == "T")
                {
                    documents.Add(new TXTHandler());
                }
                else if (format == "D")
                {
                    documents.Add(new DOCHandler());
                }
            }

            foreach (AbstractHandler doc in documents)
            {
                doc.Open();
                doc.Create();
                doc.Change();
                doc.Save();
                Console.WriteLine();
            }
            //2
            Player player = new Player();

            player.Play();
            IPlayable player1 = player as IPlayable;

            player1.Pause();
            player1.Stop();

            Console.WriteLine();

            player.Record();
            IRecodable player2 = player as IRecodable;

            player2.Pause();
            player2.Stop();

            Console.WriteLine();
            //3
            Title title = new Title
            {
                Text = "Good Book"
            };

            Author author = new Author
            {
                Text = "Saska"
            };

            Content content = new Content
            {
                Text = "Very long time ago!"
            };

            Book book = new Book(title, author, content);

            book.Show();

            Console.ReadLine();
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            IPlayable  operation1 = null;
            IRecodable operation2 = null;
            string     oper;
            bool       t = true;

            Console.Write("Please press '1' for playing music or press '2' for recording: ");

AAA:
            int press = Convert.ToInt32(Console.ReadLine());

            switch (press)
            {
            case 1:
            {
                operation1 = new Player();
                break;
            }

            case 2:
            {
                operation2 = new Player();
                break;
            }

            default:
            {
                Console.WriteLine("Please press '1' or '2'");
                goto AAA;
            }
            }

            do
            {
                if (operation1 != null)
                {
                    Console.WriteLine("Please input operation (play, pouse, stop)  for exit input (exit): ");
BBB:
                    oper = Console.ReadLine();
                    switch (oper)
                    {
                    case "play":
                    {
                        operation1.Play();
                        break;
                    }

                    case "pouse":
                    {
                        operation1.Pouse();
                        break;
                    }

                    case "stop":
                    {
                        operation1.Stop();
                        break;
                    }

                    case "exit":
                    {
                        t = false;
                        break;
                    }

                    default:
                    {
                        Console.WriteLine("Wrong operation! Please input (play | pouse | stop)  for exit input (exit)");
                        goto BBB;
                    }
                    }
                }
                else
                {
                    Console.WriteLine("Please input operation (Record, pouse, stop)  for exit input (exit): ");
CCC:
                    oper = Console.ReadLine();
                    switch (oper)
                    {
                    case "record":
                    {
                        operation2.Record();
                        break;
                    }

                    case "pouse":
                    {
                        operation2.Pouse();
                        break;
                    }

                    case "stop":
                    {
                        operation2.Stop();
                        break;
                    }

                    case "exit":
                    {
                        t = false;
                        break;
                    }

                    default:
                    {
                        Console.WriteLine("Wrong operation! Please input (record | pouse | stop)  for exit input (exit)");
                        goto CCC;
                    }
                    }
                }
            } while (t);
        }