using
using
using
using
using
using
System;
[Link];
[Link];
[Link];
[Link];
[Link];
namespace CountdownTimer
{
class CustomTimer
{
Timer timer1;
int duration;
public CustomTimer(int tickRate)
{
timer1 = new Timer(tickRate);
[Link]("\nYou've just created a timer!\n");
[Link] += new ElapsedEventHandler(MyTimer_Elapsed);
} // end Constructor
private void MyTimer_Elapsed(object sender, ElapsedEventArgs e)
{
if (duration >= 0)
{
ClearCurrentConsoleLine();
if (duration >= 25)
[Link] = [Link];
else if (duration >= 20)
[Link] = [Link];
else if (duration >= 15)
[Link] = [Link];
else if (duration >= 10)
[Link] = [Link];
else if (duration >= 5)
[Link] = [Link];
else
[Link] = [Link];
[Link]("{0}", duration);
duration--;
} // end if
else
StopMyTimer();
} // end MyTimer_Elapsed()
private void StopMyTimer()
{
[Link]();
[Link]("\n\nYour time is up!!!");
} // end StopMyTimer()
public void StartMyTimer(int newDuration)
{
duration = newDuration;
[Link]("\n\nCounting down from {0}!\n", duration);
[Link]();
} // end StartMyTimer()
private void ClearCurrentConsoleLine()
{
int currentLineCursor = [Link];
[Link](0, [Link]);
[Link](new string(' ', [Link]));
[Link](0, currentLineCursor);
} // end ClearCurrentConsoleLine()
} // end custom timer class
} // end namespace