// Path: src/net/mmberg/nadia/processor/exceptions/ProcessingException.java
// public class ProcessingException extends Exception {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public ProcessingException(String message){
// 		super("Processing Exception: "+message);
// 		NadiaProcessor.getLogger().severe(message);
// 	}
// 	
// 	public ProcessingException(){
// 		super("Processing Exception");
// 	}
// }
// 
// Path: src/net/mmberg/nadia/processor/exceptions/RuntimeError.java
// public class RuntimeError extends Exception {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public RuntimeError(String message){
// 		super("RuntimeError: "+message);
// 		NadiaProcessor.getLogger().severe(message);
// 	}
// 	
// 	public RuntimeError(){
// 		super("RuntimeError");
// 	}
// }
// 
// Path: src/net/mmberg/nadia/processor/ui/UIConsumer.java
// public class UIConsumerMessage{
// 	private String systemUtterance;
// 	private Meta meta;
// 	public enum Meta{QUESTION, ANSWER, UNCHANGED, END_OF_DIALOG, ERROR, REPEATEDQUESTION};
// 		
// 	public UIConsumerMessage(String systemUtterance, Meta meta){
// 		this.systemUtterance=systemUtterance;
// 		this.meta=meta;
// 	}
// 		
// 	public String getSystemUtterance(){
// 		return systemUtterance;
// 	}
// 		
// 	public Meta getMeta(){
// 		return meta;
// 	}
// }
// 
// Path: src/net/mmberg/nadia/processor/ui/UIConsumer.java
// public enum Meta{QUESTION, ANSWER, UNCHANGED, END_OF_DIALOG, ERROR, REPEATEDQUESTION};


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import net.mmberg.nadia.processor.exceptions.ProcessingException;
import net.mmberg.nadia.processor.exceptions.RuntimeError;
import net.mmberg.nadia.processor.ui.UIConsumer.UIConsumerMessage;
import net.mmberg.nadia.processor.ui.UIConsumer.UIConsumerMessage.Meta;

	private String receive() {
		String user_answer="";
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			user_answer = reader.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return user_answer;
	}


	@Override
	public void start() {
		try{
			consumer=consumerFactory.create();
			UIConsumerMessage message=consumer.processUtterance(null);
			String systemUtterance=message.getSystemUtterance();
			send(systemUtterance);
			
			String userUtterance;		
			while(!(userUtterance = receive()).equals("\r\n")){
				message=consumer.processUtterance(userUtterance);
				systemUtterance=message.getSystemUtterance();
				if(message.getMeta()==Meta.END_OF_DIALOG) break;
				send(systemUtterance);
			}
		}
// Path: src/net/mmberg/nadia/processor/exceptions/ProcessingException.java
// public class ProcessingException extends Exception {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public ProcessingException(String message){
// 		super("Processing Exception: "+message);
// 		NadiaProcessor.getLogger().severe(message);
// 	}
// 	
// 	public ProcessingException(){
// 		super("Processing Exception");
// 	}
// }
// 
// Path: src/net/mmberg/nadia/processor/exceptions/RuntimeError.java
// public class RuntimeError extends Exception {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public RuntimeError(String message){
// 		super("RuntimeError: "+message);
// 		NadiaProcessor.getLogger().severe(message);
// 	}
// 	
// 	public RuntimeError(){
// 		super("RuntimeError");
// 	}
// }
// 
// Path: src/net/mmberg/nadia/processor/ui/UIConsumer.java
// public class UIConsumerMessage{
// 	private String systemUtterance;
// 	private Meta meta;
// 	public enum Meta{QUESTION, ANSWER, UNCHANGED, END_OF_DIALOG, ERROR, REPEATEDQUESTION};
// 		
// 	public UIConsumerMessage(String systemUtterance, Meta meta){
// 		this.systemUtterance=systemUtterance;
// 		this.meta=meta;
// 	}
// 		
// 	public String getSystemUtterance(){
// 		return systemUtterance;
// 	}
// 		
// 	public Meta getMeta(){
// 		return meta;
// 	}
// }
// 
// Path: src/net/mmberg/nadia/processor/ui/UIConsumer.java
// public enum Meta{QUESTION, ANSWER, UNCHANGED, END_OF_DIALOG, ERROR, REPEATEDQUESTION};


// Path: src/net/mmberg/nadia/processor/ui/ConsoleInterface.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import net.mmberg.nadia.processor.exceptions.ProcessingException;
import net.mmberg.nadia.processor.exceptions.RuntimeError;
import net.mmberg.nadia.processor.ui.UIConsumer.UIConsumerMessage;
import net.mmberg.nadia.processor.ui.UIConsumer.UIConsumerMessage.Meta;


	private String receive() {
		String user_answer="";
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			user_answer = reader.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return user_answer;
	}


	@Override
	public void start() {
		try{
			consumer=consumerFactory.create();
			UIConsumerMessage message=consumer.processUtterance(null);
			String systemUtterance=message.getSystemUtterance();
			send(systemUtterance);
			
			String userUtterance;		
			while(!(userUtterance = receive()).equals("\r\n")){
				message=consumer.processUtterance(userUtterance);
				systemUtterance=message.getSystemUtterance();
				if(message.getMeta()==Meta.END_OF_DIALOG) break;
				send(systemUtterance);
			}
		}
		catch(ProcessingException ex){