Example #1
0
      /// Thoroughly test all Animal methods, with all the actions 
      ///   clearly labeled for a person *not* readingthe code.
      public static void Main()
      {  
			Animal f = new Animal ("Frog");
			Animal d = new Animal ("Dog");
			Animal c = new Animal ("Cow");

			f.Greet ();
			f.Eat ("worm"); 
			f.Eat ("corn"); 
			f.Eat ("fly"); 
			f.Eat ("bird");
			f.Excrete ();
			Console.WriteLine(f.ToString ());

			d.Greet ();
			d.Eat ("biscuit"); 
			d.Eat ("homework");
			d.Excrete ();
			Console.WriteLine(d.ToString ());

			c.Greet ();
			c.Eat ("grass"); 
			c.Excrete ();
			Console.WriteLine(c.ToString ());

      }
Example #2
0
        public static void Main()
        {
            string name = UIF.PromptLine ("What is the animal's name?");
            Animal cat = new Animal (name);
            cat.Greet ();

            string food1 = UIF.PromptLine ("What do you want "+cat.GetName()+" to eat?");
            cat.Eat (food1);
            string food2 = UIF.PromptLine ("What do you want "+cat.GetName()+" to eat?");
            cat.Eat (food2);
            string food3 = UIF.PromptLine ("What do you want "+cat.GetName()+" to eat?");
            cat.Eat (food3);
            Console.WriteLine (cat.GetName () + " now has: " + cat.Contents () + " in its stomache.");

            Console.WriteLine (cat.GetName () + " will new excrete.");
            cat.Excrete();
            Console.WriteLine (cat.GetName () + " now has: " + cat.Contents () + " in its stomache.");
            Console.WriteLine (cat.GetName () + " will new excrete.");
            cat.Excrete();
            Console.WriteLine (cat.GetName () + " now has: " + cat.Contents () + " in its stomache.");

            Console.WriteLine(cat.ToString());
        }