Exemplo n.º 1
0
        public static void headOfLine(Queue male, Queue female)
        {
            Dancer w = new Dancer();
            Dancer m = new Dancer();

            if (male.Count > 0)
            {
                m.GetName(male.Peek().ToString());
            }
            if (female.Count > 0)
            {
                w.GetName(female.Peek().ToString());
            }
            if (m.name != "" && w.name != "")
            {
                Console.WriteLine($"Next in line are:{m.name}  {w.name}");
            }
            else
            {
                if (m.name != "")
                {
                    Console.WriteLine($"Next in line is {m.name}");
                }
                else
                {
                    Console.WriteLine($"Next in line is {w.name}");
                }
            }
        }
Exemplo n.º 2
0
        public static void startDancing(Queue male, Queue female)
        {
            Dancer m = new Dancer();
            Dancer w = new Dancer();

            Console.WriteLine($"Dance parters are :");
            Console.WriteLine();
            for (int count = 0; count <= 3; count++)
            {
                m.GetName(male.Dequeue().ToString());
                w.GetName(female.Dequeue().ToString());
                Console.WriteLine($"{w.name}  {m.name}");
            }
        }
Exemplo n.º 3
0
        public static void newDancers(Queue male, Queue female)
        {
            Dancer m, w;

            m = new Dancer();
            w = new Dancer();
            if (male.Count > 0 && female.Count > 0)
            {
                //和自定义的CQueue类不同,返回并删除
                m.GetName(male.Dequeue().ToString());
                w.GetName(female.Dequeue().ToString());
            }
            else if (male.Count > 0 && female.Count == 0)
            {
                Console.WriteLine("waiting on a female dancer");
            }
            else if (male.Count == 0 && female.Count >= 0)
            {
                Console.WriteLine("waiting on a male dancer");
            }
        }