using System;
using System.Collections;
namespace ConsoleApp1
{
class Program
{
//Declaration of Queue
static Queue items = new Queue();
static void Main()
{
int option = 0; //This will handle the option number
bool loop = true; //This will continue the loop. To terminate, asign
false to loop variable
while (loop == true)
{
Console.WriteLine("Choose one option: \n1) Add a Name \n2) Remove a
Name \n3) Peek a Name \n4) Show all Names \n5) Exit\n");
//This will accept the user input
Console.Write("Enter option number: ");
option = Int32.Parse(Console.ReadLine());
//This will determine what method to call
if (option == 1)
{
addItem();
}
else if (option == 2)
{
removeItem();
}
else if (option == 3)
{
peekItem();
}
else if (option == 4)
{
showItems();
}
else
{
//This will terminate the loop.
loop = false;
Console.WriteLine("Program Terminated");
}
Console.Write("-------------------------------------\n");
}
}
public static void addItem()
{
Console.WriteLine("Option 1");
items.Enqueue("Wendell");
items.Enqueue("Allen");
items.Enqueue("Belando");
foreach (var x in items)
{
Console.WriteLine(x);
}
}
public static void removeItem()
{
Console.WriteLine("Option 2");
items.Dequeue();
foreach (var x in items)
{
Console.WriteLine(x);
}
}
public static void peekItem()
{
Console.WriteLine("Option 3");
Console.WriteLine(items.Peek());
}
public static void showItems()
{
Console.WriteLine("Option 4");
foreach (var x in items)
{
Console.WriteLine(x);
}
}
}
}