static void Main(string[] args) { ICutDownNotifier[] classes = new ICutDownNotifier[3]; timer[] t = new timer[3]; Console.WriteLine("Name of the 1st timer:"); t[0] = new timer(Console.ReadLine()); Console.WriteLine("Time to wait (seconds)"); classes[0] = new one(Convert.ToInt32(Console.ReadLine())); Console.WriteLine("Name of the 2nd timer:"); t[1] = new timer(Console.ReadLine()); Console.WriteLine("Time to wait (seconds)"); classes[1] = new one(Convert.ToInt32(Console.ReadLine())); Console.WriteLine("Name of the 3rd timer:"); t[2] = new timer(Console.ReadLine()); Console.WriteLine("Time to wait (seconds)"); classes[2] = new one(Convert.ToInt32(Console.ReadLine())); Console.WriteLine(); for (int i = 0; i < classes.Length; i++) { classes[i].init(t[i]); classes[i].run(t[i]); Console.WriteLine(); } }
public void run(timer t) { t.go(time); }
public void init(timer t) { t.start += toStart; t.left += toLeft; t.end += toEnd; }
public void init(timer t) { t.start += (string source, string name) => { Console.WriteLine($"Timer {name} (source: {source}) stareted"); }; t.left += (string source, string name, int remain) => { Console.WriteLine($"Timer {name} (source: {source}) time left: {remain}"); }; t.end += (string source, string name) => { Console.WriteLine($"Timer {name} (source: {source}) ended work"); }; }