Exemplo n.º 1
0
    public void GoToHell()
    {
        int i = 0;

        while (Arrived == false && i < 1000)
        {
            i++;
            ISlot slot = Next(CurrentDirection);
            if (slot.IsAccessible(this) == true)
            {
                Go(CurrentDirection);
                slot.Affect(this);
                continue;
            }

            foreach (string direction in Priorities)
            {
                if (direction == CurrentDirection)
                {
                    continue;
                }

                slot = Next(direction);
                if (slot.IsAccessible(this) == true)
                {
                    Go(direction);
                    slot.Affect(this);
                    break;
                }
            }
        }
        if (Arrived == false)
        {
            Console.WriteLine("LOOP");
        }
    }