sakkat

melhor solução que recebi

Sep 29th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1.     public boolean buscaBloco(int x, int y) {
  2.         mensageiro.mensagem(mensageiro.BUSCA, x, y);       
  3.         if(sala.marcadorEm(x, y) ==  ISala.BLOCO_PRESENTE){
  4.             mensageiro.mensagem(mensageiro.CAPTURA, x, y);
  5.             sala.marcar(x, y, ISala.POSICAO_VAZIA);
  6.             return true;}
  7.         sala.marcar(x, y, ISala.MARCA_PRESENTE);
  8.         if(testaPasso(x, y, DIREITA_X, DIREITA_Y))return true;
  9.         if(testaPasso(x, y, BAIXO_X, BAIXO_Y))return true;
  10.         if(testaPasso(x, y, ESQUERDA_X,ESQUERDA_Y))return true;
  11.         if(testaPasso(x, y, CIMA_X, CIMA_Y))return true;
  12.         return false;}
  13.     public void buscaBlocos() {    
  14.         boolean resultado = true;      
  15.         while(BLOCOS_RESTANTES > 0 && resultado == true){
  16.             resultado = buscaBloco(POS_X,POS_Y);
  17.             if(resultado){
  18.                 if(guardaBloco())sala.removeMarcador(ISala.MARCA_PRESENTE);}}
  19.         if(BLOCOS_RESTANTES == 0)mensageiro.msgFim();
  20.         else mensageiro.msgNaoAchou();}
Advertisement
Add Comment
Please, Sign In to add comment