class Program
{
static void Main(string[] args)
{
Boy boy = new Boy("汤姆","男",10,100);
Girl girl = new Girl("珍妮", "女", 8, 888);
Parent p = new Parent();
p.myevent += boy.BoyCall;
p.myevent += girl.GirlCall;
p.DeteCall();
Boy b1 = new Boy("汤姆", "男", 1, 100);
Boy b2 = new Boy("汤姆", "男", 3, 100);
Boy b3 = new Boy("汤姆", "男", 2, 100);
Boy b4 = new Boy("汤姆", "男", 18, 100);
Boy b5 = new Boy("汤姆", "男", 10, 100);
List<Boy> list = new List<Boy>();
list.Add(b1);
list.Add(b2);
list.Add(b3);
list.Add(b4);
list.Add(b5);
for (int i = 0; i < list.Count; i++)
{
for (int j = i; j < list.Count; j++)
{
if (list[i].Age > list[j].Age)
{
Boy temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
}
foreach (var item in list)
{
item.BoyCall();
}
Console.ReadKey();
}
}
class Parent
{
public delegate void mydete();
public event mydete myevent;
public void DeteCall()
{
Console.WriteLine("大人呼喊孩子们!");
myevent();
}
}
class Girl
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private int age;
public int Age
{
get { return age; }
set { age = value; }
}
private double proerty;
public double Proerty
{
get { return proerty; }
set { proerty = value; }
}
private string sex;
public string Sex
{
get { return sex; }
set { sex = value; }
}
public Girl(string _name, string _sex, int _age, double _proerty)
{
this.Name = _name;
this.Sex = _sex;
this.Age = _age;
this.Proerty = _proerty;
}
public void GirlCall()
{
Console.WriteLine("我叫{0},我是{1}孩,今年{2}岁了,我有{3}元,我听到父母的喊声!", this.Name, this.Sex, this.Age, this.Proerty);
}
}
class Boy
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private int age;
public int Age
{
get { return age; }
set { age = value; }
}
private double proerty;
public double Proerty
{
get { return proerty; }
set { proerty = value; }
}
private string sex;
public string Sex
{
get { return sex; }
set { sex = value; }
}
public Boy(string _name, string _sex, int _age, double _proerty)
{
this.Name = _name;
this.Sex = _sex;
this.Age = _age;
this.Proerty = _proerty;
}
public void BoyCall()
{
Console.WriteLine("我叫{0},我是{1}孩,今年{2}岁了,我有{3}元,我听到父母的喊声!", this.Name, this.Sex, this.Age, this.Proerty);
}
}