Exemple #1
0
        public static void Main(string[] args)
        {
            Person        p1     = new Person("Robert", "Bob");
            Hero          h1     = new Hero("Fireman", "John", "Fireball", null);
            Villain       v1     = new Villain("Fireman", "AquaMan", null);
            List <Person> people = new List <Person>
            {
                p1,
                h1,
                v1
            };

            foreach (Person character in people)
            {
                character.PrintGreeting();
            }
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            //create list to add humans
            List <Person> Human = new List <Person>();

            //Person
            Person person1 = new Person("Jacob", "Jake");
            Person person2 = new Person("Robert", "Bobby");
            Person person3 = new Person("Samuel", "Sam");

            //SuperHero
            SuperHero hero1 = new SuperHero("Spider-Man", "Peter Parker", "spider sense");
            SuperHero hero2 = new SuperHero("Iron Man", "Tony Stark", "super strength");
            SuperHero hero3 = new SuperHero("Black Widow", "Natasha Romanova", "expertise in the covert arts");

            //Villain
            Villain villain1 = new Villain("Lex Luthor", "Superman");
            Villain villain2 = new Villain("Loki", "Thor");
            Villain villain3 = new Villain("The Joker", "Batman");

            Human.Add(person1);
            Human.Add(person2);
            Human.Add(person3);
            Human.Add(hero1);
            Human.Add(hero2);
            Human.Add(hero3);
            Human.Add(villain1);
            Human.Add(villain2);
            Human.Add(villain3);

            foreach (var human in Human)
            {
                human.PrintGreeting();
                Console.WriteLine();
            }
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            Person a = new Person("William", "Bill");
            Person b = new Person("Robert", "Bobby");
            Person c = new Person("Lexi", "Alexis");

            SuperHero e = new SuperHero("Wade Turner", "Super Strength", "Mr.Incredible");
            SuperHero f = new SuperHero("Bruce Wayne", "Super Intelligent", "Batman");

            Villain g = new Villain("Joker", "Batman");
            Villain h = new Villain("Doc-oc", "Spiderman");

            a.PrintGreeting();
            b.PrintGreeting();
            c.PrintGreeting();
            Console.WriteLine();
            e.PrintGreeting();
            f.PrintGreeting();
            Console.WriteLine();
            g.PrintGreeting();
            h.PrintGreeting();

            Console.ReadLine();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            List <Person> humans = new List <Person>();

            Person william = new Person("William Smith", "Bill");

            humans.Add(william);

            SuperHero wade = new SuperHero("Wade Turner", "Mr. Incredible", "super strength");

            humans.Add(wade);

            Villain joker = new Villain("Jack Napier", "The Joker", "Batman");

            humans.Add(joker);

            foreach (Person human in humans)
            {
                Console.Write($"{human.Name}: ");
                human.PrintGreeting();
            }

            Console.ReadLine();
        }