Exemple #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);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("We're countin' gators 'n clonin' sheep!");

            Alligator gator = new Alligator(0);

            CountTestApp.GatorCount(gator);

            Sheep babe = new Sheep("Babe", 0);

            CountTestApp.SheepCount(babe);

            Console.WriteLine("Thanks for all your help! I feel real sleepy all of a sudden. . .");
            Console.ReadKey();
        }
Exemple #3
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());
        }
Exemple #4
0
        static void Main(string[] args)
        {
            CountTestApp.Count();

            while (true)
            {
                Console.WriteLine("Would you like to make some more sheep?\n'y' for 'Y'es, anything else for no!");

                string sheepName   = "";
                int    cloneNumber = 0;

                char answer = Console.ReadKey(true).KeyChar;

                if (answer == 'y' || answer == 'Y')
                {
                    Console.Clear();

                    sheepName = Validator.GetString("What is the name of the sheep?", @"^[A-Z][a-z]+$");

                    cloneNumber = Validator.GetNumber("How many should we make? (up too 100)", 1, 100);

                    Console.Clear();

                    Sheep userMade = new Sheep(sheepName);

                    CountUntil.Count(userMade, cloneNumber);

                    Console.WriteLine("\npress anything to continue...");
                    Console.ReadKey(true);
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine("GOODBYE!!");
                    break;
                }
            }


            Console.ReadKey();
        }
Exemple #5
0
 public static void NameSheep(Sheep sheep, string name)
 {//used exclusively to change the name of the cloned sheep
     sheep.Name = name;
 }