コード例 #1
0
ファイル: Program.cs プロジェクト: klcun94/csharp-projects
        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();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: kemora08/Csharp
        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();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: CK1962/CSharpDotNet
        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();
        }