package seedu.todo.ui;

import seedu.todo.controllers.*;

public class InputHandler {
    
    Controller handlingController = null;
    
    public void processInput(String input) {
        if (this.handlingController != null)
            handlingController.process(input);
        else {
            Controller[] controllers = instantiateAllControllers();
            float[] confidences = new float[controllers.length];
            
            // Java sucks. No map/max...
            float maxConfidence = controllers[0].inputConfidence(input);
            Controller maxController = controllers[0];
            for (int i = 0; i < controllers.length; i++) {
                float confidence = controllers[i].inputConfidence(input);
                if (confidence > maxConfidence) {
                    maxConfidence = confidence;
                    maxController = controllers[i];
                }
            }
            
            // Process using best-matched controller.
            maxController.process(input);
        }
    }
    
    private Controller[] instantiateAllControllers() {
        return new Controller[] { 
                new AddController(),
                new ListController(),
                new DestroyController(),
                new UpdateController() 
                };
    }

}

@@ -1132,33 +1132,16 @@
 ler%5B%5D %7B 
-%0A                
 new AddC
@@ -1165,24 +1165,42 @@
             
+     
+             
 new ListCont
@@ -1221,24 +1221,42 @@
             
+         
+         
 new DestroyC
@@ -1280,24 +1280,42 @@
             
+             
+     
 new UpdateCo
@@ -1325,33 +1325,16 @@
 oller() 
-%0A                
 %7D;%0A    %7D

revert as requested