コード例 #1
0
        static void Main(string[] args)
        {
            ICountable objAlligator = new Alligator();

            Console.WriteLine("Counting Alligator...");
            CountUtil.count(objAlligator, 4);
            Console.WriteLine("\n");

            ICloneable objSheep = new Sheep();

            Console.WriteLine("Counting Sheep...");
            CountUtil.count(objSheep, 3);
            Console.WriteLine("\n");
            ICloneable sheepDuplicate = objSheep.cloneAnimal(objSheep);

            CountUtil.count(sheepDuplicate, 3);
            Console.WriteLine("\n");
            objSheep.resetCount();

            CountUtil.count(objSheep, 1);
        }
コード例 #2
0
 ICloneable ICloneable.cloneAnimal(ICloneable animal)
 {
     animal = new Sheep();
     animal.setCloneName("Dolly");
     return(animal);
 }