package pt.c01interfaces.s01knowledge.s02app.actors;

import pt.c01interfaces.s01knowledge.s01base.impl.BaseConhecimento;
import pt.c01interfaces.s01knowledge.s01base.inter.IBaseConhecimento;
import pt.c01interfaces.s01knowledge.s01base.inter.IDeclaracao;
import pt.c01interfaces.s01knowledge.s01base.inter.IEnquirer;
import pt.c01interfaces.s01knowledge.s01base.inter.IObjetoConhecimento;
import pt.c01interfaces.s01knowledge.s01base.inter.IResponder;

public class Enquirer implements IEnquirer
{
    IObjetoConhecimento obj;
	
	public Enquirer()
	{
        IBaseConhecimento bc = new BaseConhecimento();
		
		obj = bc.recuperaObjeto("tiranossauro");
	}
	
	
	@Override
	public void connect(IResponder responder)
	{
		IDeclaracao decl = obj.primeira();
		
		while (decl != null && responder.ask(decl.getPropriedade()).equalsIgnoreCase(decl.getValor()))
			decl = obj.proxima();
		
		boolean acertei = false;
		
		if (decl == null)
			acertei = responder.finalAnswer("tiranossauro");
		else
			acertei = responder.finalAnswer("nao conheco");
		
		if (acertei)
			System.out.println("Oba! Acertei!");
		else
			System.out.println("fuem! fuem! fuem!");

	}

}

@@ -560,16 +560,86 @@
 ()%0D%0A%09%7B%0D%0A
+%09%7D%0D%0A%09%0D%0A%09%0D%0A%09@Override%0D%0A%09public void connect(IResponder responder)%0D%0A%09%7B%0D%0A
         
@@ -738,181 +738,295 @@
 );%0D%0A
-%09%7D%0D%0A%09%0D%0A%09%0D%0A%09@Override%0D%0A%09public void connect(IResponder responder)%0D%0A%09%7B%0D%0A%09%09IDeclaracao decl = obj.primeira();%0D%0A%09%09%0D%0A%09%09while (decl != null && responder.ask(decl.getPropriedade())
+%0D%0A%09%09IDeclaracao decl = obj.primeira();%0D%0A%09%09%0D%0A        boolean animalEsperado = true;%0D%0A%09%09while (decl != null && animalEsperado) %7B%0D%0A%09%09%09String pergunta = decl.getPropriedade();%0D%0A%09%09%09String respostaEsperada = decl.getValor();%0D%0A%09%09%09%0D%0A%09%09%09String resposta = responder.ask(pergunta);%0D%0A%09%09%09if (resposta
 .equ
@@ -1043,27 +1043,29 @@
 ase(
-decl.getValor()
+respostaEsperada
 ))%0D%0A
+%09
 %09%09%09d
@@ -1092,27 +1092,33 @@
 %0D%0A%09%09
+%09else
 %0D%0A%09%09
+%09
-boolean acertei
+%09animalEsperado
  = f
@@ -1130,34 +1130,25 @@
 %0D%0A%09%09
+%7D
 %0D%0A%09%09
-if (decl == null)%0D%0A%09%09%09
+%0D%0A%09%09boolean 
 acer
@@ -1197,68 +1197,8 @@
 );%0D%0A
-%09%09else%0D%0A%09%09%09acertei = responder.finalAnswer(%22nao conheco%22);%0D%0A
 %09%09%0D%0A

Ajuste do código para se tornar mais claro.