DIRECTIONS:
Construct a working program by dragging & dropping lines from the left to the right. You'll need to change the order of the lines and you'll need to adjust the indentation correctly.
You're given code that will present a short menu of options to the user. Your job is to add/rearrange code so that the user can type in 1 to move forwards and 2 to turn left. The program only has to do this once (instead of repeatedly asking the user and following their directions).
For this program, you should clear any remaining input as soon as you've gotten the number from the user.
import becker.robots.*;
import java.util.*;
public class MoveOrTurn extends Object
{
public static void main(String[] args)
{
City seattle = new City(); // do this first
Robot mary = new Robot(seattle, 1, 1, Direction.EAST, 0); // do this second
Scanner keyboard = new Scanner(System.in); // do this third
int option; // do this fourth
System.out.println("Please type 1 to move forwards (once)");
System.out.println("Please type 2 to turn left (once)");
System.out.println("Please type a number");
// FIX THIS PART!!! //
}
}
Check your work by clicking on the button labeled "Get Feedback" at the bottom of this page.