Create Enum for traffic signals when you select any signal it has to display a message as an instruction Use a single method to display a message. Display the number of values enum has using enum predefined methods.
public enum trafficsignal
{
green = 1,
yellow,
red,
}
static void Main(string[] args)
{
Console.WriteLine("1-Green 2-yellow 3-red ");
Console.WriteLine("Please select any one(1,2 or 3)");
int n = int.Parse(Console.ReadLine());
trafficsignal traffic = (trafficsignal)n;
switch (traffic)
{
case trafficsignal.green:
{
Console.Write("Thanku User you select is green. So You can go");
break;
}
case trafficsignal.yellow:
{
Console.WriteLine("Thanku User You select yellow. So you just wait");
break;
}
case trafficsignal.red:
{
Console.WriteLine("Thanku User You select red. So you stop");
break;
}
default:
Console.WriteLine("Invalid option");
break;
}
Console.ReadLine();
}
No comments:
Post a Comment