示例#1
0
        static void Main(string[] args)
        {
            Habitat savanna = new Habitat();

            savanna.inhabitants = new List <Animal>();

            // Animal larry = new Animal();
            // larry.name = args[0];

            // ANIMAL INSTANCES
            Zedonk   zippy  = new Zedonk("Zippy");
            Latastei marco  = new Latastei("Marco");
            Iberica  robert = new Iberica("Robert");

            savanna.inhabitants.Add(zippy);
            savanna.inhabitants.Add(marco);

            foreach (Animal a in savanna.inhabitants)
            {
                Console.WriteLine("List and foreach example: " + a.name);
            }

            // CONSOLE OUTPUT
            Console.WriteLine("Name: " + zippy.name);
            Console.WriteLine("Genus: " + zippy.genus);
            Console.WriteLine("Species: " + zippy.speciesName);
            Console.WriteLine("Common Name: " + zippy.commonName);
            Console.WriteLine("Legs: " + zippy.legs);
            Console.WriteLine("Hybrid: " + zippy.isHybrid);
            Console.WriteLine("Fertile: " + zippy.isFertile);
            Console.WriteLine("");

            Console.WriteLine("Name: " + marco.name);
            Console.WriteLine("Genus: " + marco.genus);
            Console.WriteLine("Species: " + marco.speciesName);
            Console.WriteLine("Common Name: " + marco.commonName);
            Console.WriteLine("Legs: " + marco.legs);
            Console.WriteLine("Color: " + marco.color);
            Console.WriteLine("Override test: " + marco.doSomething());
            Console.WriteLine("");

            Console.WriteLine("Name: " + robert.name);
            Console.WriteLine("Genus: " + robert.genus);
            Console.WriteLine("Species: " + robert.speciesName);
            Console.WriteLine("Common Name: " + robert.commonName);
            Console.WriteLine("Legs: " + robert.legs);
            Console.WriteLine("Color: " + robert.color);
            Console.WriteLine("Override test: " + robert.doSomething());
            Console.WriteLine("");
        }
示例#2
0
        static void Main(string[] args)
        {
            /*LION TEST*/
            Lion charlie = new Lion
            {
                name = "Charlie"
            };

            charlie.species = new PantheraLeo();

            Console.WriteLine("{0} the {1} in the genus {2}. To find out more visit {3}.",
                              charlie.name,
                              charlie.species.commonName,
                              charlie.species.genus.scientificName,
                              charlie.species.url);


            /*ROYAL PENGUIN TEST*/
            RoyalPenguin rita = new RoyalPenguin
            {
                name = "Rita"
            };

            rita.species = new EudyptesSchlegeli();

            Console.WriteLine("{0} the {1} in the genus {2}. To find out more visit {3}.",
                              rita.name,
                              rita.species.commonName,
                              rita.species.genus.scientificName,
                              rita.species.url);


            /*WHITE TAILED PRAIRIE DOG TEST*/
            WhiteTailedPrairieDog walter = new WhiteTailedPrairieDog
            {
                name = "Walter"
            };

            walter.species = new CynomysLeucurus();

            Console.WriteLine("{0} the {1} in the genus {2}. To find out more visit {3}.",
                              walter.name,
                              walter.species.commonName,
                              walter.species.genus.scientificName,
                              walter.species.url);



            /* HABITAT */
            Habitat savanna = new Habitat();

            savanna.inhabitants = new List <Animal>();

            savanna.inhabitants.Add(charlie);
            savanna.inhabitants.Add(rita);
            savanna.inhabitants.Add(walter);

            foreach (Animal a in savanna.inhabitants)
            {
                Console.WriteLine("{0} is a {1}.", a.name, a.species.commonName);
            }


            Habitat aquarium = new Habitat();

            Habitat prairie = new Habitat();



            Console.ReadLine();
        }