Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication51
- {
- class Program
- {
- int x;
- static string[] thequeue = new string[11];
- static int frontpointer = 0;
- static int rearpointer = -1;
- static void Main(string[] args)
- {
- int x =0;
- while (x<1)
- {
- int input;
- Console.WriteLine(" 1) Add New Customer");
- Console.WriteLine(" 2) Check Next Customer to Be Served ");
- Console.WriteLine(" 3) Serve Next Customer ");
- input = Convert.ToInt32(Console.ReadLine());
- if (input == 1)
- {
- Console.WriteLine("Please enter customer name");
- enqueue(Console.ReadLine());
- }
- if (input == 2)
- {
- Console.WriteLine("The latest customer is ... " + peek());
- }
- if (input == 3)
- {
- Console.WriteLine("Serving the next customer " + dequeue());
- }
- Console.WriteLine("Would you like to continue?");
- string decision = Console.ReadLine();
- if (decision == "yes")
- {
- x = 0;
- }
- else if (decision == "no")
- {
- x = 1;
- }
- }
- }
- static void enqueue (string item)
- {
- rearpointer++;
- thequeue[rearpointer%10] = item;
- }
- static string dequeue()
- {
- string item;
- item = thequeue[frontpointer%10];
- thequeue[frontpointer] = "";
- frontpointer++;
- return thequeue[frontpointer];
- }
- static string peek()
- {
- return thequeue[frontpointer];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement