Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Media;
- namespace BozzaTimer
- {
- class Timer
- {
- static void Main(/*string[] args*/)
- {
- string secondi_s, ripetizioni_s;
- int secondi, ripetizioni;
- bool secIsNum, ripIsNum;
- // User interaction
- Console.WriteLine("This program is a simple loop timer. It beeps every x seconds for y consecutive times.");
- Console.WriteLine("How many repetitions?");
- ripetizioni_s = Console.ReadLine();
- ripIsNum = int.TryParse(ripetizioni_s, out ripetizioni);
- Console.WriteLine("How many seconds inbetween?");
- secondi_s = Console.ReadLine();
- secIsNum = int.TryParse(secondi_s, out secondi);
- if (secIsNum == true && ripIsNum == true)
- {
- Console.WriteLine("Press any key to continue...");
- Console.ReadKey();
- StartTimer(secondi, ripetizioni);
- }
- else
- Console.WriteLine("Wrong input, try not to fuck up next time. Protip: you need to write an integer number.");
- Console.WriteLine("Press any key to exit...");
- Console.ReadKey();
- }
- static void StartTimer(int sec, int rip)
- {
- /*int Freq, Dur, FreqEnd, DurEnd;
- Freq = 6000; // Set Frequency To 6000 Hertz
- Dur = 800; // Set Duration To 800 ms == 0.8 second
- FreqEnd = 3000; // Set Frequency To 3000 Hertz
- DurEnd = 1000; // Set Duration To 1000 ms == 1 second*/
- SoundPlayer begin, beep, beep2, horn;
- int sleepTime = sec * 1000;
- begin = new SoundPlayer(ConsoleApplication1.Properties.Resources.begin);
- beep = new SoundPlayer(ConsoleApplication1.Properties.Resources.beep_07);
- beep2 = new SoundPlayer(ConsoleApplication1.Properties.Resources.beep);
- horn = new SoundPlayer(ConsoleApplication1.Properties.Resources.horn);
- //Countdown timer
- Thread.Sleep(2000);
- Console.Write("3.. ");
- beep.Play();
- Thread.Sleep(1000);
- Console.Write("2.. ");
- beep.Play();
- Thread.Sleep(1000);
- Console.Write("1.. ");
- beep.Play();
- Thread.Sleep(1000);
- Console.WriteLine("Begin!");
- begin.Play();
- //Looped part
- for (int i = 1; i <= rip; i++)
- {
- Console.WriteLine("Round " + i);
- Thread.Sleep(sleepTime);
- beep2.Play();
- }
- Console.WriteLine("Good job!");
- horn.Play();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement