예제 #1
0
 public void DeQueue(QueueCreep theQueue)
 {
     if (QueueLength > 0)
     {
         object found = queueCreep[0];
         Front = Front + 1 % MaxSize;
         QueueLength--;
     }
 }
예제 #2
0
 public void EnQueue(QueueCreep theQueue)
 {
     if (QueueLength > MaxSize)
     {
         queueCreep[Back] = theQueue;
         Back             = Back + 1;
         QueueLength++;
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            QueueShunt    MyQueueShunt = new QueueShunt(10);
            QueueCreep    MyQueueCreep = new QueueCreep(10);
            QueueCircular Myqueue      = new QueueCircular(10);
            bool          running;

            Console.WriteLine("Select which process you would like to run by typing in it's letter in capitals. The maximum size of the queue is 10");
            running = true;

            while (running == true)
            {
                Console.WriteLine("A. Add Person");
                Console.WriteLine("B. Remove Person");
                Console.WriteLine("C. View Queue Length");
                Console.WriteLine("D. Quit");
                Console.ReadLine();
            }

            switch (Console.ReadLine())
            {
            case "A":     //Enqueue
            {
                Console.WriteLine("Type what you want to add to the queue");
                Myqueue.EnQueue(Console.ReadLine());
                break;
            }

            case "B":     //Dequeue
            {
                Console.WriteLine("Type what you need to remove from the queue");
                Myqueue.DeQueue(Console.ReadLine());
                break;
            }

            case "C":
            {
                Console.WriteLine("The queue length is:" + Myqueue.length);
                break;
            }

            case "D":
            {
                running = false;
                Console.WriteLine("Press enter to exit program");
                Console.ReadKey();
                break;
            }
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World! welcome to the queue!");
            int        menuinput;
            QueueCreep myQueue = new QueueCreep();
            string     theName;

            do
            {
                Console.WriteLine("please enter what you wish to do");
                Console.WriteLine("press 1 to add an entity to the queue");
                Console.WriteLine("press 2 to remove an entity to the queue");
                Console.WriteLine("press 3 to give the queue's length");
                Console.WriteLine("press 4 to display the queue");
                Console.WriteLine("press 5 to quit");
                menuinput = Convert.ToInt32(Console.ReadLine());

                if (menuinput == 1)
                {
                    Console.WriteLine("please type in the name");
                    theName = Console.ReadLine();
                    myQueue.add(theName);
                    Console.WriteLine("entered succesfully!");
                }
                if (menuinput == 2)
                {
                    myQueue.Remove();
                }
                if (menuinput == 3)
                {
                    myQueue.Length();
                }
                if (menuinput == 4)
                {
                    myQueue.display();
                }
            } while (menuinput != 5);
            Console.WriteLine("thank you!");
            Console.ReadLine();
        }
예제 #5
0
        static void Main(string[] args)
        {
            QueueCreep Queue = new QueueCreep();

            int option = 0;

            do
            {
                Console.WriteLine(" 1. Add person to queue. ");
                Console.WriteLine(" 2. remove person from queue. ");
                Console.WriteLine(" 3. length of queue. ");
                Console.WriteLine(" 4. display queue. ");
                Console.WriteLine(" 5. Quite. ");
                option = Convert.ToInt32(Console.ReadLine());

                switch (option)
                {
                case 1:

                    break;

                case 2:

                    break;

                case 3:

                    break;

                case 4:

                    break;

                default:
                    Console.WriteLine("incorrect key entered");
                    break;
                }
            }while (option != 5);
        }