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(); }
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); foreach (Person item in persons) { item.GetConclusion(); } }
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 GetWonmanConclusion(Woman woman) { Console.WriteLine($"{woman.GetType().Name}{this.GetType().Name}时,凡事懂也装不懂"); }
public override void GetWonmanConclusion(Woman woman) { Console.WriteLine($"{woman.GetType().Name}{this.GetType().Name}时,背后大多有一个不成功的男人"); }
public abstract void GetWonmanConclusion(Woman woman);
public override void GetWomanConclusion(Woman concreteElementB) { Console.WriteLine("{0}{1}时,欣慰曰:爱情长跑路漫漫,婚姻保险保平安。", concreteElementB.GetType().Name, this.GetType().Name); }
public override void GetWomanConclusion(Woman concreteElementB) { Console.WriteLine("{0}{1}时,遇事懂也装作不懂", concreteElementB.GetType().Name, this.GetType().Name); }
//得到女人结论或反应 public abstract void GetWomanConclusion(Woman concreteElementB);
public override void GetWomanConclusion(Woman concreteElementB) { Console.WriteLine("{0}{1}时,眼泪汪汪,谁也劝不了。", concreteElementB.GetType().Name, this.GetType().Name); }
public override void GetWomanConclusion(Woman concreteElementB) { Console.WriteLine("{0}{1}时,背后大多有一个不成功的男人。", concreteElementB.GetType().Name, this.GetType().Name); }