@@ -0,0 +1,3212 @@
+package babysteps.model;%0A%0Aimport java.util.List;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.ObjectInputStream;%0Aimport java.io.ObjectOutputStream;%0Aimport java.util.stream.Collectors;%0A%0Apublic class TaskModel %7B%0A    %0A    /**%0A     * Top of the task B-tree. All subtasks should be contained within this instance.%0A     */%0A    private Task currentTask;%0A    %0A    /**%0A     * Constructor.%0A     */%0A    public TaskModel() %7B%0A        currentTask = new Task(%22Tasks%22);%0A    %7D%0A    %0A    /**%0A     * Provide all of the subtask titles.%0A     * %0A     * @return a List of strings%0A     */%0A    public List%3CString%3E subtaskNames() %7B%0A        return currentTask.getSubtasks().stream()%0A                .map(Task::getTitle)%0A                .collect(Collectors.toList());%0A    %7D%0A    %0A    /**%0A     * Return the head of the task tree.%0A     * %0A     * @return a Task instance%0A     */%0A    public Task getCurrentTask() %7B%0A        return currentTask;%0A    %7D%0A    %0A    /**%0A     * Add a child to the current task.%0A     * %0A     * @param title%0A     */%0A    public void createTask(String title) %7B%0A        currentTask.getSubtasks().add(new Task(title, currentTask));%0A    %7D%0A    %0A    /**%0A     * Move down the tree to a specific task.%0A     * %0A     * @param taskNumber%0A     */%0A    public void enterTask(int taskNumber) %7B%0A        currentTask = currentTask.getSubtasks().get(taskNumber);%0A    %7D%0A    %0A    /**%0A     * Go to the task above this one in the task tree.%0A     */%0A    public void moveUp() %7B%0A        currentTask.getParent().ifPresent(t -%3E currentTask = t);%0A    %7D%0A    %0A    /**%0A     * Find the top of the task tree. i.e. discover the most general task.%0A     * %0A     * @return the parent task%0A     */%0A    private Task headTask() %7B%0A        Task place = currentTask;%0A        while(place.getParent().isPresent()) %7B%0A            place = place.getParent().get();%0A        %7D%0A        return place;%0A    %7D%0A    %0A    /**%0A     * Save all tasks (including parents) to the given file.%0A     * %0A     * @param file%0A     * @return true if successful, false otherwise%0A     */%0A    public boolean serialize(String path) %7B%0A        try %7B%0A            FileOutputStream fileOut = new FileOutputStream(path);%0A            ObjectOutputStream out = new ObjectOutputStream(fileOut);%0A            out.writeObject(headTask());%0A            out.close();%0A            fileOut.close();%0A            return true;%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A            return false;%0A        %7D%0A    %7D%0A    %0A    /**%0A     * Overwrite the entire model with a new task tree. The previous task tree is not saved.%0A     * %0A     * @param file%0A     * @return true if successful, false otherwise%0A     */%0A    public boolean deseriablize(String path) %7B%0A        try %7B%0A            FileInputStream fileIn = new FileInputStream(path);%0A            ObjectInputStream in = new ObjectInputStream(fileIn);%0A            currentTask = (Task) in.readObject();%0A            in.close();%0A            fileIn.close();%0A            return true;%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A            return false;%0A        %7D catch (ClassNotFoundException e) %7B%0A            e.printStackTrace();%0A            return false;%0A        %7D%0A    %7D%0A%7D%0A

Implement a main model class with serialization