年度单身舞会队列
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace TestOfQueueDancers
{
class Program
{
static void Main(string[] args)
{
Queue males = new Queue();
Queue females = new Queue();
FormLines(males,females);
StartDancing(males,females);
if (males.Count > 0 || females.Count > 0)
{
HeadOfLine(males,females);
}
NewDancers(males,females);
if (males.Count > 0 || females.Count > 0)
{
HeadOfLine(males,females);
}
NewDancers(males,females);
Console.WriteLine("Press Enter");
}
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.Write("Wating for female dancer.");
}
else if ((female.Count > 0) && (male.Count == 0))
{
Console.Write("Wating for male dancer.");
}
}
public static void HeadOfLine(Queue male, Queue female)
{
Dancer w, m;
w = new Dancer();
m = new Dancer();
if (male.Count > 0)
{
m.GetName(male.Peek().ToString());
}
if (female.Count > 0)
{
w.GetName(female.Peek().ToString());
}
if (!string.IsNullOrEmpty(m.name) &&
!string.IsNullOrEmpty(w.name))
{
Console.WriteLine("Next in line are:" + m.name + "\t" + w.name);
}
else
{
if (!string.IsNullOrEmpty(m.name))
{
Console.WriteLine("Next in line is:" + m.name);
}
else
{
Console.WriteLine("Next in line is:" + w.name);
}
}
}
public static void StartDancing(Queue male, Queue female)
{
Dancer m, w;
m = new Dancer();
&nb
补充:软件开发 , C# ,