Exemplo n.º 1
0
 public static Nullable <Direction> TryParse(string str)
 {
     if (str.Length > 1)
     {
         return(null);
     }
     return(DirectionUtilities.TryParse(str[0]));
 }
Exemplo n.º 2
0
        public static Rover TryParse(Plateau plateau, string str)
        {
            var parts = str.Split(" ", StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length != 3)
            {
                return(null);
            }
            else
            {
                var position  = Position.FromStrings(parts[0], parts[1]);
                var direction = DirectionUtilities.TryParse(parts[2]);
                if (position != null && direction != null)
                {
                    return(new Rover(plateau, position.Value, direction.Value));
                }
                else
                {
                    return(null);
                }
            }
        }