private void init() { inputParser = new ParserMain(); storageSystem = new StorageMain(); masterListTasks = new ArrayList<Task>(); completeTasks = new ArrayList<Task>(); incompleteTasks = new ArrayList<Task>(); state = new ArrayList<ArrayList<Task>>(); masterListTasks = new ArrayList<Task>(storageSystem.loadTask()); }
/** * Changes file save location. * * @param taskToOp * @return feedback message */ private String doSave(Task taskToOp) { String feedBack; String newLoc = taskToOp.get_task(); assert newLoc != null; assert newLoc != SYMBOL_EMPTY; if (!newLoc.isEmpty()) { try { storageSystem.saveFileLocation(newLoc); feedBack = taskToOp.get_messageToUserSuccess(); } catch (Exception e) { log.log(Level.SEVERE, e.toString(), e); feedBack = taskToOp.get_messageToUserFail(); } } else { feedBack = taskToOp.get_messageToUserFail(); } return feedBack; }
/** * Method processes user input by calling dependencies Parser and LogicHandler * * @param userInput is the input received from UI. * @return feedBack message generated by command. */ public String processCommand(String userInput) { String[] formattedInput = inputParser.processInput(userInput); ArrayList<ArrayList<String>> dateTimeArgs = inputParser.processDateTime(userInput); Task newCreatedTask = LogicHandler.processCommand(formattedInput, dateTimeArgs); String feedbackToUI = operateOnTask(newCreatedTask); logList(); if (isMutatorAndNotUndoRedo(newCreatedTask)) { updateState(); } sortList(); regenerateSubListsFromMasterList(); if (!isSearchOrDisplay(newCreatedTask)) { updateOperating(); } logList(); storageSystem.storageWrite(masterListTasks); return feedbackToUI; }