Lo que se hizo en el ejercicio 4 dentro del código fue agregar dentro del método move();
Agregamos uno de los métodos proporcionados, de manera que las coordenadas estaban compuestas por (0,1), (1,0), (-1,0), (0,-1). La manera que se pusieron dependía el camino que tomaban, pero aquí el usuario ingresa la posición donde el robot debe moverse.
Este el codigo que se agrego al programa para poder trabajar como se muestra a continuacion.
System.out.println("The makeMove method was called.");
if(getContents(0,1)==GOAL||getContents(-1,0)==GOAL||
getContents(1,0) ==GOAL || getContents(0,-1) == GOAL)
return false;
if(notWall(1,0)){
if(getMarks(1,0)<=getMarks(-1,0)&&getMarks(1,0)<=getMarks(0,1)&&
getMarks(1,0)<=getMarks(0,-1)){
if(cell[currentRow][currentCol]>=0)cell[currentRow][currentCol]++;
return true;
}
}
if(notWall(0,1)){
if(getMarks(0,1)<=getMarks(-1,0)&&getMarks(0,1)<=getMarks(1,0)&&
getMarks(0,1)<=getMarks(0,-1)){
if(cell[currentRow][currentCol]>=0)cell[currentRow][currentCol]++;
return true;
}
}
if(notWall(-1,0)){
if(getMarks(-1,0)<=getMarks(1,0)&&getMarks(-1,0)<=getMarks(0,1)&&
getMarks(-1,0)<=getMarks(0,-1)){
if(cell[currentRow][currentCol]>=0)cell[currentRow][currentCol]++;
return true;
}
}
if(notWall(0,-1)){
if(getMarks(0,-1)<=getMarks(-1,0)&&getMarks(0,-1)<=getMarks(1,0)&&
getMarks(0,-1)<=getMarks(0,1)){
if(cell[currentRow][currentCol]>=0)cell[currentRow][currentCol]++;
return true;
}
}
viernes, 3 de octubre de 2014
Proyecto 04
8:05
No comments
Suscribirse a:
Enviar comentarios (Atom)







0 comentarios:
Publicar un comentario