static void Main(string[] args) { Player player = new Player(); int choice; do { Console.Clear(); Console.WriteLine("1.Play\n2.Record\n0.Exit"); choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: player.Play(); Thread.Sleep(1000); ((IPayable)player).Pause(); ((IPayable)player).Stop(); Console.ReadKey(); break; case 2: player.Record(); Thread.Sleep(1000); ((IRecodable)player).Pause(); ((IRecodable)player).Stop(); Console.ReadKey(); break; default: Console.WriteLine("Goodbye!"); break; } } while (choice != 0); player.Play(); }
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; } }
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; } }
static void Main(string[] args) { IPlayable playable = new Player(); IRecodable recodable = new Player(); playable.Play(); playable.Pause(); playable.Stop(); Console.WriteLine(); recodable.Record(); recodable.Pause(); recodable.Stop(); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Player#1"); Player Player1 = new Player(); Player1.Play(); (Player1 as IPlayable).Stop(); Player1.Record(); (Player1 as IRecodable).Stop(); Console.WriteLine("Player#2"); Player Player2 = new Player(); Player2.Play(); (Player2 as IPlayable).Stop(); Player2.Record(); (Player2 as IRecodable).Stop(); }
static void Main(string[] args) { Console.WriteLine("Type QUIT to quit from player"); Player p = new Player(); while (true) { Console.WriteLine("\nInput operation (play/record/pause/stop):"); string action = Console.ReadLine(); switch (action) { case "play": p.Play(); break; case "record": p.Record(); break; case "pause": p.Pause(); break; case "stop": p.Stop(); break; case "QUIT": return; default: Console.WriteLine("Unknown operation"); break; } } }