There is a Robot whose starting position(0,0) and end position(5,3)
.I showed the direction it take to go start to goal position.
I want to implement a GUI according to this picture in java. That means whenever I click in the run button a window appear which show the robot is moving within a grid.
I try to implement a code in java to implement the movement.But this is only a raw code.Failed to implement the GUI. My code is like that. I have a robot class and a grid that I define in the variable Grid.
Public class Robot{
int[][] grid = new int[][]{{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}};
int North=0;int East=1;int South=2;int west=3;
public void forward() {
switch (orientation) {
case "north":
if (grid.isValid(position.x, position.y+1)) {
position.y += 1;
} else {
System.out.println("Can't go there!");
}
break;
}
}
Like that.... Now can anyone help me to give a suggestion to display the GUI in Java. I don't want to use in build simulator.