Advertisement
vencinachev

TrafficLights

Nov 20th, 2021
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. namespace Loops
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Console.Write("Time for RED signal [sec]: ");
  11.             int redTime = int.Parse(Console.ReadLine());
  12.             Console.Write("Time for GREEN signal [sec]: ");
  13.             int greenTime = int.Parse(Console.ReadLine());
  14.  
  15.             while (true)
  16.             {
  17.                 Console.Clear();
  18.                 Console.WriteLine("RED");
  19.                 Thread.Sleep(redTime * 1000);
  20.                 Console.Clear();
  21.                 Console.WriteLine("RED, YELLOW");
  22.                 Thread.Sleep(1000);
  23.                 Console.Clear();
  24.                 Console.WriteLine("GREEN");
  25.                 Thread.Sleep(greenTime * 1000);
  26.                 Console.Clear();
  27.                 Console.WriteLine("YELLOW");
  28.                 Thread.Sleep(1000);
  29.             }
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement