コード例 #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;
            }
        }
コード例 #2
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;
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: fagot2005/C_Sharp_new
        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();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: shara25/CyberBionic
        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();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Fyntiche/MyPractice
        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();
        }
コード例 #6
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();
        }
コード例 #7
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();
        }
コード例 #8
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();
        }
コード例 #9
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();
        }
コード例 #10
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");
            }
コード例 #11
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;
            }
            }
        }
コード例 #12
0
ファイル: Menu.cs プロジェクト: vslavchumakov/ISDInitiative
        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);
        }
コード例 #13
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();
        }