예제 #1
0
        public void Move(string name)
        {
            name = name.ToUpper();

            if (name.Length > 0)
            {
                if (TheFarmer == "North" && NorthBank.Contains(name))
                {
                    NorthBank.Remove(name);
                    SouthBank.Add(name);
                    TheFarmer = Direction.South.ToString();
                }
                else if (TheFarmer == "South" && SouthBank.Contains(name))
                {
                    SouthBank.Remove(name);
                    NorthBank.Add(name);
                    TheFarmer = Direction.North.ToString();
                }
            }
            else
            {
                //move farmer
                if (TheFarmer == "North")
                {
                    TheFarmer = Direction.South.ToString();
                }
                else if (TheFarmer == "South")
                {
                    TheFarmer = Direction.North.ToString();
                }
            }
        }
예제 #2
0
 public Boolean AnimalAteFood()
 {
     Console.Write("\t");
     if (TheFarmer == "North")
     {
         if ((SouthBank.Contains("CHICKEN") && SouthBank.Contains("GRAIN")))
         {
             Console.WriteLine("The Chicken ate the Grain!");
             return(true);
         }
         else if ((SouthBank.Contains("CHICKEN") && SouthBank.Contains("FOX")))
         {
             Console.WriteLine("The Fox ate the Chicken!");
             return(true);
         }
     }
     else if (TheFarmer == "South")
     {
         if ((NorthBank.Contains("CHICKEN") && NorthBank.Contains("GRAIN")))
         {
             Console.WriteLine("The Chicken ate the Grain!");
             return(true);
         }
         else if ((NorthBank.Contains("CHICKEN") && NorthBank.Contains("FOX")))
         {
             Console.WriteLine("The Fox ate the Chicken!");
             return(true);
         }
     }
     return(false);
 }