Exemple #1
0
        public void Move()
        {
            var direction = Rotation.GetDirection();

            switch (direction)
            {
            case "N":
                _coordinate = Coordinate.SetY(Coordinate.Y + 1);
                break;

            case "S":
                _coordinate = Coordinate.SetY(Coordinate.Y - 1);
                break;

            case "E":
                _coordinate = Coordinate.SetX(Coordinate.X + 1);
                break;

            case "W":
                _coordinate = Coordinate.SetX(Coordinate.X - 1);
                break;

            default:
                throw new ArgumentException("Invalid Direction");
            }
        }
Exemple #2
0
 public override string ToString()
 {
     if (_isCrashed)
     {
         return($"{Name} is crashed. Last coords: {Coordinate.ToString()} {Rotation.GetDirection()}");
     }
     return($"{Name} - {Coordinate.ToString()} {Rotation.GetDirection()}");
 }