コード例 #1
0
        public static Sheep Cloner(Sheep sheep)
        {//clones a sheep from an input sheep, renames it, and resets the count to 0
            Sheep dolly = (Sheep)sheep.Clone();

            Sheep.NameSheep(dolly, GetName());
            dolly.ResetCount();
            return(dolly);
        }
コード例 #2
0
        public static void SheepCount(Sheep sheep)
        {//takes an input sheep, counts to an input,
         //clones it, counts the clone to another input,
         //then resets the original sheep and counts to a final input
            Console.WriteLine("Counting sheep. . .");
            CountUtil.Count(sheep, Counter());

            Console.WriteLine("Cloning sheep. . .");
            Sheep dolly = Cloner(sheep);

            CountUtil.Count(dolly, Counter());

            Console.WriteLine("Counting sheep. . .");
            sheep.ResetCount();
            CountUtil.Count(sheep, Counter());
        }