protected override void Move(NavInstruction instruction) { if (instruction.Action is 'L' or 'R') { Rotate(instruction.Action, instruction.Value); return; } Move(GetDirection(instruction), instruction.Value); }
protected override void Move(NavInstruction instruction) { if (instruction.Action is 'L' or 'R') { Rotate(instruction.Action, instruction.Value); return; } if (instruction.Action is 'F') { for (int i = 0; i < instruction.Value; i++) { Location = new Point(Location.X + Waypoint.X, Location.Y + Waypoint.Y); } return; } Waypoint = Move(Waypoint, GetDirection(instruction), instruction.Value); }
protected Direction GetDirection(NavInstruction instruction) => instruction.Action switch { 'N' => Direction.Up,