Пример #1
0
        static void Main(string[] args)
        {
            string C = args[0];
            string k = args[1];
            string p = args[2];
            string c = args[3];
            int passed = 0;
            int failed = 0;
            int total = 0;

            LifeForm l = new LifeForm(0);
            switch (C){
                case "Mammal":
                    Mammal cat = new Mammal(1);
                    l = cat;
                    break;
                case "Reptile":
                    Reptile alligator = new Reptile(2);
                    l = alligator;
                    break;
                case "Bird":
                    Bird parakeet = new Bird(3);
                    l = parakeet;
                    break;
            }
            try{
                HasCorrectKingdom(l,k);
                passed++;
            }
            catch(NUnit.Framework.AssertionException e){
                testFailed(e);
                failed++;
            }
            total ++;
            try{
             HasCorrectPhylum(l,p);
             passed++;

             }
             catch(NUnit.Framework.AssertionException e){
             	testFailed(e);
             	failed++;
             }
             total ++;
             try{
                HasCorrectClass(l,c );
                passed++;
            }
            catch (NUnit.Framework.AssertionException e) {
                testFailed(e);
                failed++;
            }
            total ++;
            Console.WriteLine(total.ToString() + " tests run, " + passed.ToString() + " tests passed, " + failed.ToString() + " tests failed.\nPress any key to continue...");
            Console.ReadKey(true);
        }
Пример #2
0
 static void Main(string[] args)
 {
     Reptile alligator = new Reptile(0);
     Console.WriteLine("An alligator belongs to the kingdom " + alligator.get_kingdom());
     Console.WriteLine("An alligator belongs to the phylum " + alligator.get_phylum());
     Console.WriteLine("An alligator belongs to the class " + alligator.get_class());
     Console.WriteLine("Press any key to continue...");
     Console.ReadKey(true);
     Bird parakeet = new Bird(1);
     Console.WriteLine("A parakeet belongs to the kingdom " + parakeet.get_kingdom());
     Console.WriteLine("A parakeet belongs to the phylum " + parakeet.get_phylum());
     Console.WriteLine("A parakeet belongs to the class " + parakeet.get_class());
     Console.WriteLine("Press any key to continue...");
     Console.ReadKey(true);
     Mammal cat = new Mammal(2);
     Console.WriteLine("A cat belongs to the kingdom " + cat.get_kingdom());
     Console.WriteLine("A cat belongs to the phylum " + cat.get_phylum());
     Console.WriteLine("A cat belongs to the class " + cat.get_class());
     Console.WriteLine("Press any key to continue...");
     Console.ReadKey(true);
 }