Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- namespace Merry_Christmas
- {
- internal class Program : ISoundProvider
- {
- public Program(string[] frames)
- {
- var frameManager = new FrameManager(frames, 220);
- var soundManager = new SoundManager(this);
- frameManager.Run();
- soundManager.Run();
- }
- // ReSharper disable once InconsistentNaming
- private static int Main(string[] args)
- {
- var program = new Program(new[]
- {
- Frames.FRAME1, Frames.FRAME2, Frames.FRAME3, Frames.FRAME4, Frames.FRAME5, Frames.FRAME6, Frames.FRAME7,
- Frames.FRAME8, Frames.FRAME9, Frames.FRAME10, Frames.FRAME11, Frames.FRAME12, Frames.FRAME13,
- Frames.FRAME14, Frames.FRAME15, Frames.FRAME16, Frames.FRAME17, Frames.FRAME18, Frames.FRAME19,
- Frames.FRAME20, Frames.FRAME21, Frames.FRAME22, Frames.FRAME23, Frames.FRAME24, Frames.FRAME25,
- Frames.FRAME26
- });
- return program.exitCode();
- }
- private int exitCode()
- {
- while ((uint)Console.ReadKey().Key != 27) { }
- return 0;
- }
- public IEnumerable<ISoundCommand> GetCommmands()
- {
- yield return new BeepCommand(659, 400);
- yield return new WaitForMsCommand(50);
- yield return new BeepCommand(659,400);
- yield return new WaitForMsCommand(50);
- yield return new BeepCommand(659,800);
- yield return new WaitForMsCommand(50);
- yield return new BeepCommand(659,400);
- yield return new WaitForMsCommand(50);
- yield return new BeepCommand(659,400);
- yield return new WaitForMsCommand(50);
- yield return new BeepCommand(659,800);
- yield return new WaitForMsCommand(50);
- yield return new BeepCommand(659,400);
- yield return new WaitForMsCommand(50);
- yield return new BeepCommand(783,400);
- yield return new WaitForMsCommand(50);
- yield return new BeepCommand(523,400);
- yield return new WaitForMsCommand(50);
- yield return new BeepCommand(587,400);
- yield return new WaitForMsCommand(50);
- yield return new BeepCommand(659, 800);
- }
- }
- internal class FrameManager
- {
- private readonly string[] m_frames;
- private readonly int m_waitDelay;
- public FrameManager(string[] frameArray, int waitDelay)
- {
- m_frames = frameArray;
- m_waitDelay = waitDelay;
- }
- public void Run()
- {
- Task.Factory.StartNew(() =>
- {
- foreach (var frame in m_frames)
- {
- Console.Clear();
- Console.WriteLine(frame);
- Task.Delay(m_waitDelay).Wait();
- }
- });
- }
- }
- internal class SoundManager
- {
- private readonly ISoundProvider m_provider;
- private IEnumerable<ISoundCommand> m_data;
- public SoundManager(ISoundProvider provider)
- {
- m_provider = provider;
- }
- public void Run()
- {
- m_data = m_provider.GetCommmands();
- Task.Factory.StartNew(() =>
- {
- foreach (var command in m_data)
- command.Execute();
- });
- }
- }
- internal interface ISoundProvider
- {
- IEnumerable<ISoundCommand> GetCommmands();
- }
- internal interface ISoundCommand
- {
- void Execute();
- }
- internal class BeepCommand : ISoundCommand
- {
- private readonly int frequency;
- private readonly int duration;
- public BeepCommand(int frequency, int duration)
- {
- this.frequency = frequency;
- this.duration = duration;
- }
- public void Execute()
- {
- Console.Beep(frequency, duration);
- }
- }
- internal class WaitForMsCommand : ISoundCommand
- {
- private readonly int ms;
- public WaitForMsCommand(int ms)
- {
- this.ms = ms;
- }
- public void Execute()
- {
- Task.Delay(ms).Wait();
- }
- }
- internal class Frames
- {
- #region Frames
- public const string FRAME1 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. M |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME2 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Me |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME3 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Mer |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME4 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merr |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME5 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME6 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry C |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME7 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Ch |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME8 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Chr |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME9 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Chri |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME10 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christ |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME11 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christm |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME12 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christma |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME13 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME14 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME15 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) H |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME16 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Ha |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME17 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Hap |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME18 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Happ |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME19 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Happy |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME20 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Happy N |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME21 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Happy Ne |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME22 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Happy New |
- | * '^' . |
- | |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME23 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Happy New |
- | * '^' . |
- | Y |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME24 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Happy New |
- | * '^' . |
- | Ye |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME25 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Happy New |
- | * '^' . |
- | Yea |
- `-------------------------------------------------------------------'
- ";
- public const string FRAME26 = @"
- .----------------------_._------------------------------------------.
- | d888b . * |
- | . * _ ?888P_ . |
- | ,-~~-'-/_~~~\.'-~:8o. * |
- | ,' .:8bv' .:88. . |
- | / .:88 .:8b . . . |
- | . / .:8P .:8b |
- | ,' .:8P\ .:88. Merry Christmas |
- | ,=' .:88 \ __:88g_ |
- | -._ .:8| | _..-~,~ ~;' & * |
- | ~o..__ .:8| | _-~ ?8b_ _.-' |
- | ~~ ~~--.:88 /:___...(888) Happy New |
- | * '^' . |
- | Year |
- `-------------------------------------------------------------------'
- ";
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement