static void Main(string[] args) { IList<Person> persons = new List<Person>(); Person man1 = new Man(); man1.Action = "成功"; persons.Add(man1); Person woman1 = new Woman(); woman1.Action = "成功"; persons.Add(woman1); Person man2 = new Man(); man2.Action = "失败"; persons.Add(man2); Person woman2 = new Woman(); woman2.Action = "失败"; persons.Add(woman2); Person man3 = new Man(); man3.Action = "恋爱"; persons.Add(man3); Person woman3 = new Woman(); woman3.Action = "恋爱"; persons.Add(woman3); foreach (Person item in persons) { item.GetConclusion(); } Console.Read(); }
public override void GetManConclusion(Man concreteElementA) { Console.WriteLine("{0}{1}时,感慨道:恋爱游戏终结时,‘有妻徒刑’遥无期。", concreteElementA.GetType().Name, this.GetType().Name); }
//得到男人结论或反应 public abstract void GetManConclusion(Man concreteElementA);
public override void GetManConclusion(Man concreteElementA) { Console.WriteLine("{0}{1}时,闷头喝酒,谁也不用劝。", concreteElementA.GetType().Name, this.GetType().Name); }
public override void GetManConclusion(Man concreteElementA) { Console.WriteLine("{0}{1}时,背后多半有一个伟大的女人", concreteElementA.GetType().Name, this.GetType().Name); }