Advertisement
Guest User

Untitled

a guest
May 12th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Media;
  7.  
  8. namespace BozzaTimer
  9. {
  10.     class Timer
  11.     {
  12.         static void Main(/*string[] args*/)
  13.         {
  14.             string secondi_s, ripetizioni_s;
  15.             int secondi, ripetizioni;
  16.             bool secIsNum, ripIsNum;
  17.                        
  18.             // User interaction
  19.             Console.WriteLine("This program is a simple loop timer. It beeps every x seconds for y consecutive times.");
  20.             Console.WriteLine("How many repetitions?");
  21.             ripetizioni_s = Console.ReadLine();
  22.             ripIsNum = int.TryParse(ripetizioni_s, out ripetizioni);
  23.             Console.WriteLine("How many seconds inbetween?");
  24.             secondi_s = Console.ReadLine();
  25.             secIsNum = int.TryParse(secondi_s, out secondi);
  26.             if (secIsNum == true && ripIsNum == true)
  27.             {
  28.                 Console.WriteLine("Press any key to continue...");
  29.                 Console.ReadKey();
  30.                 StartTimer(secondi, ripetizioni);
  31.             }
  32.             else
  33.                 Console.WriteLine("Wrong input, try not to fuck up next time. Protip: you need to write an integer number.");
  34.             Console.WriteLine("Press any key to exit...");
  35.             Console.ReadKey();
  36.         }
  37.  
  38.         static void StartTimer(int sec, int rip)
  39.         {
  40.             /*int Freq, Dur, FreqEnd, DurEnd;
  41.             Freq = 6000; // Set Frequency To 6000 Hertz
  42.             Dur = 800; // Set Duration To 800 ms == 0.8 second
  43.             FreqEnd = 3000; // Set Frequency To 3000 Hertz
  44.             DurEnd = 1000; // Set Duration To 1000 ms == 1 second*/
  45.             SoundPlayer begin, beep, beep2, horn;
  46.             int sleepTime = sec * 1000;
  47.             begin = new SoundPlayer(ConsoleApplication1.Properties.Resources.begin);
  48.             beep = new SoundPlayer(ConsoleApplication1.Properties.Resources.beep_07);
  49.             beep2 = new SoundPlayer(ConsoleApplication1.Properties.Resources.beep);
  50.             horn = new SoundPlayer(ConsoleApplication1.Properties.Resources.horn);
  51.  
  52.             //Countdown timer
  53.             Thread.Sleep(2000);
  54.             Console.Write("3.. ");
  55.             beep.Play();
  56.             Thread.Sleep(1000);
  57.             Console.Write("2.. ");
  58.             beep.Play();
  59.             Thread.Sleep(1000);
  60.             Console.Write("1.. ");
  61.             beep.Play();
  62.             Thread.Sleep(1000);
  63.             Console.WriteLine("Begin!");
  64.             begin.Play();
  65.  
  66.             //Looped part
  67.             for (int i = 1; i <= rip; i++)
  68.             {
  69.                 Console.WriteLine("Round " + i);
  70.                 Thread.Sleep(sleepTime);
  71.                 beep2.Play();                
  72.             }
  73.  
  74.             Console.WriteLine("Good job!");
  75.             horn.Play();
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement