package pt.c02classes.s01knowledge.s02app.actors;

import java.util.Scanner;

import pt.c02classes.s01knowledge.s01base.inter.IEnquirer;
import pt.c02classes.s01knowledge.s01base.inter.IResponder;

public class EnquirerMaze implements IEnquirer {

	IResponder responder;
	
	public void connect(IResponder responder) {
		this.responder = responder;
	}
	
	public boolean discover() {
		Scanner scanner = new Scanner(System.in);
		
		System.out.print("(P)ergunta, (M)ovimento ou (F)im? ");
		String tipo = scanner.nextLine();
		while (!tipo.equalsIgnoreCase("F")) {
		   System.out.print("  --> ");
		   String pc = scanner.nextLine();
		   switch (tipo.toUpperCase()) {
		      case "P": String resposta = responder.ask(pc);
		                System.out.println("  Resposta: " + resposta);
		                break;
		      case "M": boolean moveu = responder.move(pc);
		                System.out.println((moveu)?"  Movimento executado!":"No  possvel mover");
		                break;
		   }
			System.out.print("(P)ergunta, (M)ovimento ou (F)im? ");
			tipo = scanner.nextLine();
		}
		
		if (responder.finalAnswer("cheguei"))
			System.out.println("Voc encontrou a saida!");
		else
			System.out.println("Fum fum fum!");
		
		scanner.close();
		
		return true;
	}
	
}

@@ -447,212 +447,145 @@
 %0A%09%09S
-ystem.out.print(%22(P)ergunta, (M)ovimento ou (F)im? %22);%0D%0A%09%09String tipo = scanner.nextLine();%0D%0A%09%09while (!tipo.equalsIgnoreCase(%22F%22)) %7B%0D%0A%09%09   System.out.print(%22  --%3E %22);%0D%0A%09%09   String pc = scanner.nextLine();
+tring tipo = %22P%22;%0D%0A%09%09String%5B%5D direction = %7B%22norte%22, %22leste%22, %22oeste%22, %22sul%22%7D;%0D%0A%09%09int i =0;%0D%0A%09%09%0D%0A%09%09while (!tipo.equalsIgnoreCase(%22F%22)) %7B%0D%0A
 %0D%0A%09%09
@@ -668,18 +668,28 @@
 der.ask(
-pc
+direction%5Bi%5D
 );%0D%0A%09%09  
@@ -706,54 +706,326 @@
     
-System.out.println(%22  Resposta: %22 + resposta);
+if(resposta.equalsIgnoreCase(%22passagem%22))%0D%0A%09%09                %09tipo = %22M%22;%0D%0A%09%09                else%7B%0D%0A%09%09%09                if(resposta.equalsIgnoreCase(%22saida%22))%0D%0A%09%09%09                %09tipo = %22F%22;%0D%0A%09%09%09                else%7B%0D%0A%09%09%09                %09i++;%0D%0A%09%09                %09%09tipo = %22P%22;%0D%0A%09%09%09                %7D%0D%0A%09%09                %7D
 %0D%0A%09%09
@@ -1101,10 +1101,20 @@
 ove(
-pc
+direction%5Bi%5D
 );%0D%0A
@@ -1189,15 +1189,18 @@
 %22:%22N
+%C3%A3
 o 
+%C3%A9
  poss
+%C3%AD
 vel 
@@ -1231,122 +1231,251 @@
     
-break;%0D%0A%09%09   %7D%0D%0A%09%09%09System.out.print(%22(P)ergunta, (M)ovimento ou (F)im? %22);%0D%0A%09%09%09tipo = scanner.nextLine();%0D%0A%09%09%7D%0D%0A%09%09
+%0D%0A%09%09                i=0;%0D%0A%09%09                tipo = %22P%22;%0D%0A%09%09                break;%0D%0A%09%09   %7D%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09boolean moveu = responder.move(direction%5Bi%5D);%0D%0A        System.out.println((moveu)?%22  Movimento executado!%22:%22N%C3%A3o %C3%A9 poss%C3%ADvel mover%22);%0D%0A        
 %0D%0A%09%09
@@ -1539,16 +1539,17 @@
 tln(%22Voc
+%C3%AA
  encontr
@@ -1601,16 +1601,19 @@
 (%22Fu
+%C3%A9
 m fu
+%C3%A9
 m fu
+%C3%A9
 m!%22)

Update EnquirerMaze.java