示例#1
0
        static void headOfLine(Queue male, Queue female)
        {
            Dancer w, m;

            m = new Dancer();
            w = 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 + "\t" + w.name);
            }
            else
            {
                if (m.name != "")
                {
                    Console.WriteLine("Next in line is: ", m.name);
                }
                else
                {
                    Console.WriteLine("Next in line is: ", w.name);
                }
            }
        }
示例#2
0
        static void startDancing(Queue male, Queue female)
        {
            Dancer m, w;

            m = new Dancer();
            w = new Dancer();
            Console.WriteLine("Dance partners are: ");
            Console.WriteLine();

            for (int count = 0; count < 3; count++)
            {
                m.GetName(male.Dequeue().ToString());
                w.GetName(female.Dequeue().ToString());
                Console.WriteLine(w.name + "\t" + m.name);
            }
        }
示例#3
0
        static void newDancers(Queue male, Queue female)
        {
            Dancer m, w;

            m = new Dancer();
            w = new Dancer();
            if (male.Count > 0 && female.Count > 0)
            {
                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 (female.Count > 0 && male.Count == 0)
            {
                Console.WriteLine("Waiting on a male dancer.");
            }
        }
示例#4
0
        static void formLines(Queue male, Queue female)
        {
            Dancer       d = new Dancer();
            StreamReader inFile;

            inFile = File.OpenText(@"d:\dancers.dat");
            string line;

            while (inFile.Peek() != -1)
            {
                line   = inFile.ReadLine();
                d.sex  = line.Substring(0, 1);
                d.name = line.Substring(2, line.Length - 2);
                if (d.sex == "M")
                {
                    male.Enqueue(d);
                }
                else
                {
                    female.Enqueue(d);
                }
            }
        }