I'm trying to finish this code..I'm still getting errors..can some plese help me!
[TEX]
import java.util.Scanner;
import java.util.Random;
public class robot
{
public static void main (String args [])
{
int robot_x = 0;
int robot_y = 0;
int robot_m_x = 0;
int robot_m_y = 0;
int[] robot_instructions = new int[64];
int i = 0;
int robot_state = 0;
robot_instructions[0] = 1;
maze[4][5] = 2;
maze[6][7] = 3;
maze[1][1] = 1;
maze[8][8] = 4;
maze[3][2] = 3;
maze[4][1] = 2;
robot_x = 1;
robot_y = 1;
robot_state = 1;
Random rand = new Random();
for(int i = 0; i < 64; i++)
{
int robot_instructions[i] = rand.nextInt(4);
switch(robot_instructions[i])
{
case 1:robot_x = robot_m_x;
robot_y = robot_m_y + 1; //move
break;
case 2:robot_x = robot_m_x;
robot_y = robot_m_y + 2 ; //jump
break;
case 3:
robot_x = robot_m_x - 1; //Left
break;
case 4:
robot_x = robot_m_x + 1; //Right
break;
}
}
System.out.println("Robot final location X: " + robot_x + " Y: " + robot_y);
System.out.println ("Robot State: ");
if ( ((robot_x == 4) && (robot_y == 5)) || ((robot_x == 4) && (robot_y == 1)))
{
System.out.println("Robot has fallen into a chasm");
else if((robot_x == 6) && (robot_y == 7)) || ((robot_x == 3) && (robot_y == 2));
{
System.out.println("Robot has fallen into a trap");
else if((robot_x == 8) && (robot_y == 8));
{
System.out.println("Robot has reached Destination");
else
{
System.out.println("Robot is at a safe place");
switch(robot_state[i])
{
case 1:robot_state = 1; //safe
System.out.println ( "Robot is at a safe place");
break;
case 2:robot_state = 2; //chasm
System.out.println ("Robot falls into Chasm");
break;
case 3:robot_state = 3; //trap
System.out.println("Robot falls into the trap");
break;
case 4:robot_state = 4; //destination
System.out.println( "Robot reaches Destination");
break;
case 5:robot_state = 5; //Failed
System.out.println ( "Robot fails to reach Destination");
break;
}
}
}