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(); } }
static void Main(string[] args) { ICutDownNotifier[] interfaceArray = new ICutDownNotifier[3]; // работаем с массивом объектов типа IcutDownNotifier ReversTimer[] RtArray = new ReversTimer[3]; Console.Write("Введите имя первого таймера: "); RtArray[0] = new ReversTimer(Console.ReadLine()); Console.Write("Установите время: "); interfaceArray[0] = new TimerMethod(Convert.ToInt32(Console.ReadLine())); Console.Write("Введите имя второго таймера: "); RtArray[1] = new ReversTimer(Console.ReadLine()); Console.Write("Установите время: "); interfaceArray[1] = new TimerMethod(Convert.ToInt32(Console.ReadLine())); Console.Write("Введите имя третьего таймера: "); RtArray[2] = new ReversTimer(Console.ReadLine()); Console.Write("Установите время: "); interfaceArray[2] = new TimerMethod(Convert.ToInt32(Console.ReadLine())); Console.WriteLine(); for (int i = 0; i < interfaceArray.Length; i++) { interfaceArray[i].init(RtArray[i]); interfaceArray[i].Run(RtArray[i]); Console.WriteLine(); } }
static void Run() { ICutDownNotifier[] arr = new ICutDownNotifier[3]; arr[0] = new A(5, "Чтение задания"); arr[1] = new B(5, "Выполнение задания"); arr[2] = new C(5, "Проверка задания перед отправкой"); arr[0].Init(); arr[1].Init(); arr[2].Init(); arr[0].Run(); arr[1].Run(); arr[2].Run(); }
static void Main(string[] args) { ICutDownNotifier[] array = new ICutDownNotifier[3]; array[0] = new FirstListener(4, "Чтение задания"); array[1] = new SecondListener(5, "Выполнение задания"); array[2] = new ThirdListener(2, "Проверка задания перед отправкой"); array[0].Init(); array[1].Init(); array[2].Init(); array[0].Run(); array[1].Run(); array[2].Run(); Console.ReadKey(); }
static void Main(string[] args) { StartHandler del = Start; Action <String, String> timeOver = TimeOver; ICutDownNotifier[] classes = new ICutDownNotifier[] { new Class1("Чтение задания", del, timeOver), new Class2("Выполнение задания", del, timeOver), new Class3("Проверка задания перед отправкой", del, timeOver) }; foreach (var cl in classes) { cl.Init(); cl.Run(); } Console.ReadKey(); }
static void Main() { Timer[] timers = { new Timer("таймер экзамена"), new Timer("таймер игры"), new Timer("Бессмысленный таймер") }; Person[] participants = { new Person { FirstName = "Ivan", LastName = "Petrov" }, new Person { FirstName = "Captain", LastName = "America" }, new Person { FirstName = "Tim", LastName = "Corey" } }; ICutDownNotifier[] notifiers = { new Exam("математика"), new EliminationGame(participants), new TimerReporter() }; Task[] tasks = new Task[notifiers.Length]; for (int i = 0; i < tasks.Length; i++) { notifiers[i].Initialize(timers[i]); ICutDownNotifier n = notifiers[i]; Timer t = timers[i]; tasks[i] = Task.Run(() => n.Run(t, 10000, 1000)); } Task.WaitAll(tasks); }
static void Main() { Core.Timer.StartCountdownHandler startCountdown = StartTimeTask; Action <string, string> timeComplete = StopTimeTask; var timers = new ICutDownNotifier[] { new HandlesEventsUsingMethods("Чтение задания", startCountdown, timeComplete), new HandlesEventsUsingAnonymousDelegates("Выполнение задания", startCountdown, timeComplete), new HandlesEventsUsingLambda("Проверка задания перед отправкой", startCountdown, timeComplete), }; Console.WriteLine("Enter the number of seconds for the timer"); var stringTimeLeft = Console.ReadLine(); int.TryParse(stringTimeLeft, out var timeLeft); foreach (var timer in timers) { timer.Init(); timer.Run(timeLeft); } }