package seedu.taskboss.logic.commands;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

import seedu.taskboss.logic.commands.exceptions.CommandException;

//@@author A0138961W
/**
 * Saves the data at specific filepath. Creates filepath if it does not exist
 */

public class SaveCommand extends Command {

    private static final String SYMBOL_ASTERISK = "*";
    private static final String SYMBOL_CARET = "^";
    private static final String SYMBOL_HASH = "#";
    private static final String SYMBOL_PLUS = "+";
    public static final String COMMAND_WORD = "save";
    public static final String COMMAND_WORD_SHORT = "sv";

    public static final String MESSAGE_USAGE = COMMAND_WORD
                + "Saves the data at specific filepath.\n"
                + "Example: " + COMMAND_WORD
                + " C://user/desktop/taskboss";

    public static final String MESSAGE_SUCCESS = "The data has been saved!";

    public static final String MESSAGE_INVALID_FILEPATH = "The filepath is invalid.";

    private final String filepath;

    public SaveCommand(String filepath) {
        this.filepath = filepath;
    }

    @Override
    public CommandResult execute() throws CommandException {
        assert storage != null;
        File f = new File(filepath);

        if (filepath.contains(SYMBOL_PLUS) || filepath.contains (SYMBOL_HASH) ||
                filepath.contains (SYMBOL_CARET) || filepath.contains (SYMBOL_ASTERISK)) {
            throw new CommandException(MESSAGE_INVALID_FILEPATH);
        } else if (!f.canWrite()) {
            throw new CommandException(MESSAGE_INVALID_FILEPATH);
        }

        try {
            Path path = Paths.get(filepath);
            storage.setFilePath(path.toAbsolutePath().toString());
            model.saveTaskboss();
            return new CommandResult(MESSAGE_SUCCESS);
        } catch (IOException e) {
            throw new CommandException(MESSAGE_INVALID_FILEPATH);
        }
    }
}

@@ -455,18 +455,17 @@
 BOL_
-CARE
+LEF
 T = %22
-%5E
+%3C
 %22;%0A 
@@ -506,17 +506,18 @@
 BOL_
-HASH
+RIGHT
  = %22
-#
+%3E
 %22;%0A 
@@ -558,17 +558,71 @@
 BOL_
-PLUS = %22+
+QUESTION = %22?%22;%0A    private static final String SYMBOL_BAR = %22%7C
 %22;%0A 
@@ -1416,12 +1416,11 @@
 BOL_
-PLUS
+BAR
 ) %7C%7C
@@ -1450,12 +1450,12 @@
 BOL_
-HASH
+LEFT
 ) %7C%7C
@@ -1501,12 +1501,12 @@
 BOL_
-CARE
+RIGH
 T) %7C
@@ -1542,16 +1542,75 @@
 STERISK)
+ %7C%7C%0A                    filepath.contains (SYMBOL_QUESTION)
 ) %7B%0A    

Update SaveCommand.java