示例#1
0
        public static void RecordFunc(IPlayable player1, IRecordable player2)
        {
            player2.Record();
            Console.WriteLine("Please select the next command: pause or stop!");
            string action = Console.ReadLine();

            switch (action)
            {
            case "pause": player2.Pause();
                Console.WriteLine("Please select your next step: stop or record again!");
                string actionNext = Console.ReadLine();
                switch (actionNext)
                {
                case "stop": player2.Stop(); break;

                case "record": RecordFunc(player1, player2); break;

                default: Console.WriteLine("Please select a valid command!"); break;
                }
                break;

            case "stop": player2.Stop(); break;

            default: Console.WriteLine("Please select a valid command!"); break;
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            //создание экземпляра класса Player
            Player somePlayer = new Player();

            //вызов метода Play из интерфейса IPlayable
            somePlayer.Play();

            //upcast к интерфесу IPlayable
            IPlayable somePlayerAsIPlayable = somePlayer as IPlayable;

            //после upcast возможно вызвать методы Pause и Stop интерфеса IPlayable
            somePlayerAsIPlayable.Pause();
            somePlayerAsIPlayable.Stop();

            //вызов метода Record из интерфейса IRecordable
            somePlayer.Record();

            //upcast к интерфесу IPlayable
            IRecordable somePlayerAsIRecordable = somePlayer as IRecordable;

            //после upcast возможно вызвать методы Pause и Stop интерфеса IPlayable
            somePlayerAsIRecordable.Pause();
            somePlayerAsIRecordable.Stop();
        }
示例#3
0
        static void Main(string[] args)
        {
            Player      player       = new Player();
            IRecordable recordDevice = player;
            IPlayable   playerDevice = player;

            recordDevice.Record();
            recordDevice.Pause();
            recordDevice.Stop();

            playerDevice.Play();
            playerDevice.Pause();
            playerDevice.Stop();

            Console.ReadLine();
        }
示例#4
0
        static void Main(string[] args)
        {
            Player playAndRecord = new Player();

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

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

            playAndRecord.Record();
            IRecordable recorder = playAndRecord as IRecordable;

            recorder.Pause();
            recorder.Stop();
        }
示例#5
0
        static void Main(string[] args)
        {
            Player    player = new Player();
            IPlayable music  = player;

            music.Play();
            music.Pause();
            music.Stop();

            IRecordable recorder = player;

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

            Console.ReadKey();
        }
示例#6
0
        static void Main(string[] args)
        {
            Player    player         = new Player();
            IPlayeble playeblaPlayer = player as IPlayeble;

            playeblaPlayer.Play();
            playeblaPlayer.Stop();
            playeblaPlayer.Pause();

            IRecordable recoPlayer = player as IRecordable;

            recoPlayer.Record();
            recoPlayer.Pause();
            recoPlayer.Stop();

            Console.ReadLine();
        }
示例#7
0
文件: Program.cs 项目: of22/Essential
        //Создайте 2 интерфейса IPlayable и IRecodable.В каждом из интерфейсов создайте по 3 метода void Play() / void Pause() / void Stop() и void Record() / void Pause() / void Stop() соответственно.
        //Создайте производный класс Player от базовых интерфейсов IPlayable и IRecodable.
        //Написать программу, которая выполняет проигрывание и запись.

        static void Main()
        {
            Player      player     = new Player();
            IPlayable   playable   = player;
            IRecordable recordable = player;

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

            Console.WriteLine();

            recordable.Record();
            recordable.Pause();
            (player as IRecordable).Stop();

            Console.ReadLine();
        }
示例#8
0
        static void Main(string[] args)
        {
            Player player = new Player();

            IRecordable irec = player;
            IPlayable   ipl  = player;

            irec.Record();
            irec.Pause();
            irec.Stop();
            Console.WriteLine();
            ipl.Play();
            ipl.Pause();
            ipl.Stop();

            Console.WriteLine();
            Console.ReadLine();
        }
示例#9
0
        static void Main(string[] args)
        {
            Player player = new Player();

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

            player1?.Pause();
            player1?.Stop();
            Console.WriteLine(new string('-', 80));
            player.Record();
            IRecordable recorder1 = player as IRecordable;

            recorder1.Pause();
            recorder1.Stop();

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Player player = new Player();

            Console.WriteLine("***Player***");
            IPlayable player1 = player;

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

            Console.WriteLine();

            Console.WriteLine("***Recorder***");
            IRecordable recorder = player;

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

            Console.ReadKey();
        }
示例#11
0
文件: Program.cs 项目: UomaShu/ISDdz
        static void Main(string[] args)
        {
            bool        flag = true;
            int         choice;
            Player      player            = new Player();
            IPlayable   playableMethods   = player;
            IRecordable recordableMethods = player;

            Console.WriteLine("Добро пожаловать в плеер! Выберите, что вы хотите сделать:");
            Console.WriteLine("1.Начать проигрывание");
            Console.WriteLine("2.Поставить проигрывание на паузу");
            Console.WriteLine("3.Остановить проигрыывание");
            Console.WriteLine("4.Начать запись");
            Console.WriteLine("5.Поставить запись на паузу");
            Console.WriteLine("6.Остановить запись");
            Console.WriteLine("7.Выключить");
            while (flag)
            {
                choice = int.Parse(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    player.Play();
                    Console.WriteLine("Выберете следующие действие:");
                    break;

                case 2:
                    playableMethods.Pause();
                    Console.WriteLine("Выберете следующие действие:");
                    break;

                case 3:
                    playableMethods.Stop();
                    Console.WriteLine("Выберете следующие действие:");
                    break;

                case 4:
                    player.Record();
                    Console.WriteLine("Выберете следующие действие:");
                    break;

                case 5:
                    recordableMethods.Pause();
                    Console.WriteLine("Выберете следующие действие:");
                    break;

                case 6:
                    recordableMethods.Stop();
                    Console.WriteLine("Выберете следующие действие:");
                    break;

                case 7:
                    Console.WriteLine("Выключение");
                    flag = false;
                    break;

                default:
                    Console.WriteLine("Неверный ввод!");
                    break;
                }
            }
            Console.ReadKey();
        }
示例#12
0
 private void btRecordPause_Click(object sender, EventArgs e) => _recorder.Pause();