Skip to content

Instantly share code, notes, and snippets.

@incorelabs
Created October 21, 2017 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save incorelabs/d8323b73c0ad24a8d1cb963430e260ff to your computer and use it in GitHub Desktop.
Save incorelabs/d8323b73c0ad24a8d1cb963430e260ff to your computer and use it in GitHub Desktop.
Robot Run
package Robot;
import java.util.*;
import javax.swing.*;
public class RobotRun {
// Main entry point for this example
public static void main(String args[]) {
String numberOfRows = JOptionPane.showInputDialog("Enter the number of rows");
String numberOfColumns = JOptionPane.showInputDialog("Enter the number of columns");
String roomDescription = numberOfRows + " " + numberOfColumns;
RobotRoom aNewRoom = new RobotRoom(roomDescription);
JOptionPane.showMessageDialog(null, "Where do you want to put the Robot?");
String robotLocationXString = JOptionPane.showInputDialog("Enter a X co-ordinate for the Robot");
int robotLocationX = Integer.parseInt(robotLocationXString);
String robotLocationYString = JOptionPane.showInputDialog("Enter a Y co-ordinate for the Robot");
int robotLocationY = Integer.parseInt(robotLocationYString);
String directionString = JOptionPane.showInputDialog("Which Direction the Robot should face?\n(0 = NORTH)\n(1 = EAST)\n(2 = SOUTH)\n(3 = WEST)");
int direction = Integer.parseInt(directionString);
Robot myRobot = new Robot(robotLocationX, robotLocationY, direction, aNewRoom);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment