public void moveRobot(Robot r) { r.movement = Console.ReadLine(); // to read the movement instructions for the robot char[] moves = r.movement.ToCharArray(); //adding every instruction in an array to move the robot accordingly foreach (char move in moves) // for every move, check the position and carry out the action { if (move == 'L') { r.turnLeft(); } else if (move == 'R') { r.turnRight(); } else if (move == 'M') { if (r.direction == 'E') { r.moveEast(newArena.x); } else if (r.direction == 'W') { r.moveWest(); } else if (r.direction == 'N') { r.moveNorth(newArena.y); } else if (r.direction == 'S') { r.moveSouth(); } else { Console.WriteLine("Invalid Direction"); } } else { Console.WriteLine("Invalid Move!"); } } }