public MainWindow() { InitializeComponent(); Person[] people = new Person[5]; people[0] = new SuperHero("Jon", "Holmes"); people[1] = new Villian() { FirstName = "Bill", LastName = "Gates" }; people[2] = new Citizen() { FirstName = "Mike", LastName = "Wazowski" }; people[3] = new MegaHero("Mega", "Mind"); people[4] = new Villian(); for (int i = 0; i < people.Length; i++) { Person p = people[i]; string s = p.Sing(); Type t = p.GetType(); if (t == typeof(SuperHero)) { s += " is Super"; } else if (t == typeof(Villian)) { s += " is Misunderstood Person"; } lbCalls.Items.Add(s); } IPowered ip = new MegaHero("Bob", "Smith"); lbCalls.Items.Add(ip.CanFly()); lbCalls.Items.Add(((MegaHero)ip).FirstName); SuperHero s1 = new SuperHero("Brian", "Renolds"); Villian vil = new Villian() { FirstName = "Bob", LastName = "Ross" }; lbCalls.Items.Add(s1.ToString()); string s2 = (vil + s1) + vil; int a = 1 + 2; lbCalls.Items.Add(s2); lbCalls.Items.Add(s1.ToString()); }
public override Person CopyMe() { Villian vc = new Villian(); vc.FirstName = this.FirstName; vc.LastName = this.LastName; vc.Personality = this.Personality; vc.MiddleName = this.MiddleName; vc.DateOfBirth = this.DateOfBirth; return(vc); }