|
class InterpretadorController { |
|
cadastrarTexto = () => { |
|
CadastroDeTextoPage(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
fazerPergunta = (interpretador) => { |
|
PerguntaPage(interpretador); |
|
} |
|
|
|
inserirTexto = () => { |
|
|
|
|
|
|
|
const textoElement = document.getElementById("texto"); |
|
|
|
const texto = textoElement.value; |
|
const interpretador = new Interpretador(texto); |
|
PerguntaPage(interpretador); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
mostrarQuestoes = (interpretador) => { |
|
QuestoesPage(interpretador); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
mostrarTexto = (interpretador) => { |
|
TextoPage(interpretador); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
responder = async (interpretador) => { |
|
|
|
|
|
|
|
const perguntaElement = document.getElementById("pergunta"); |
|
|
|
const texto = interpretador.getTexto(); |
|
const pergunta = perguntaElement.value; |
|
const service = new InterpretadorService(); |
|
await service.responder(texto, pergunta).then((response) => { |
|
const resposta = response.resposta; |
|
const questao = new Questao(pergunta, resposta); |
|
interpretador.adicionarQuestao(questao); |
|
this.mostrarQuestoes(interpretador); |
|
}).catch((error) => { |
|
ErroPage("Não foi possível obter resposta.", interpretador); |
|
}); |
|
|
|
} |
|
} |