Skip to content

Commit

Permalink
add more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Yikai-Cao committed Sep 30, 2022
1 parent 2a0f837 commit d95c806
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public void run() {
}
}

/**
* Set the filePath and activate run function.
*/
public static void main(String[] args) {
new Duke("./data/tasks.txt").run();
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/duke/command/ByeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public ByeCommand() {
isExit = true;
}

/**
* Execute user's "bye" command and change the storage file accordingly.
* @param taskList The list containing tasks.
* @param ui dealing with interactions with the user.
* @param storage The storage file of tasks.
*/
public void execute(TaskList taskList, Ui ui, Storage storage) {
ArrayList<Task> tasks = taskList.getTasks();
System.out.println(" Bye. Hope to see you again soon!");
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/duke/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,28 @@ public abstract class Command {
String keyword;
String statement;
Boolean isExit = false;

/**
* Execute a specific user's command and change the storage file accordingly.
* @param taskList The list containing tasks.
* @param ui dealing with interactions with the user.
* @param storage The storage file of tasks.
*/
public abstract void execute(TaskList taskList, Ui ui, Storage storage);

/**
* Decide if the user wants to quit.
*/
public Boolean isExit() {
return isExit;
}

/**
* Create a directory "data" if not exists to contain the "tasks.txt".
* @param ui dealing with interactions with the user.
* @param tasks the task list.
* @param storage The storage file of tasks.
*/
static void createDirectory(Ui ui, Storage storage, ArrayList<Task> tasks) {
ui.showLine();
System.out.println(" Seems the data directory doesn't exist yet. Try to create for you!");
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/duke/command/DeadlineCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public DeadlineCommand(String keyword, String statement) {
this.keyword = keyword;
this.statement = statement;
}

/**
* Execute user's "deadline" command and change the storage file accordingly.
* @param taskList The list containing tasks.
* @param ui dealing with interactions with the user.
* @param storage The storage file of tasks.
*/
public void execute(TaskList taskList, Ui ui, Storage storage) {
ArrayList<Task> tasks = taskList.getTasks();
tryAddDeadline(tasks, statement);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/duke/command/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public DeleteCommand(String keyword, String statement) {
this.keyword = keyword;
this.statement = statement;
}

/**
* Execute user's "delete" command and change the storage file accordingly.
* @param taskList The list containing tasks.
* @param ui dealing with interactions with the user.
* @param storage The storage file of tasks.
*/
public void execute(TaskList taskList, Ui ui, Storage storage) {
ArrayList<Task> tasks = taskList.getTasks();
tryDeleteTask(tasks, statement);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/duke/command/EventCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ public EventCommand(String keyword, String statement) {
this.keyword = keyword;
this.statement = statement;
}

/**
* Execute user's "event" command and change the storage file accordingly.
* @param taskList The list containing tasks.
* @param ui dealing with interactions with the user.
* @param storage The storage file of tasks.
*/
public void execute(TaskList taskList, Ui ui, Storage storage) {
ArrayList<Task> tasks = taskList.getTasks();
tryAddEvent(tasks, statement);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/duke/command/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ public FindCommand(String statement) {
this.statement = statement;
}

/**
* Execute user's "find" command.
* @param taskList The list containing tasks.
* @param ui dealing with interactions with the user.
* @param storage The storage file of tasks.
*/
@Override
public void execute(TaskList taskList, Ui ui, Storage storage) {
ArrayList<Task> tasks = taskList.getTasks();
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/duke/command/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public ListCommand(String keyword, String statement) {
this.statement = statement;
}

/**
* Execute user's "list" command.
* @param taskList The list containing tasks.
* @param ui dealing with interactions with the user.
* @param storage The storage file of tasks.
*/
public void execute(TaskList taskList, Ui ui, Storage storage) {
ArrayList<Task> tasks = taskList.getTasks();
printTaskList(tasks);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/duke/command/MarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ public MarkCommand(String keyword, String statement) {
this.keyword = keyword;
this.statement = statement;
}

/**
* Execute user's "mark" command and change the storage file accordingly.
* @param taskList The list containing tasks.
* @param ui dealing with interactions with the user.
* @param storage The storage file of tasks.
*/
public void execute(TaskList taskList, Ui ui, Storage storage) {
ArrayList<Task> tasks = taskList.getTasks();
tryMarkTask(tasks, statement);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/duke/command/TodoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ public TodoCommand(String keyword, String statement) {
this.keyword = keyword;
this.statement = statement;
}

/**
* Execute user's "todoTask" command and change the storage file accordingly.
* @param taskList The list containing tasks.
* @param ui dealing with interactions with the user.
* @param storage The storage file of tasks.
*/
public void execute(TaskList taskList, Ui ui, Storage storage) {
ArrayList<Task> tasks = taskList.getTasks();
tryAddTodo(tasks, statement);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/duke/command/UnmarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public UnmarkCommand(String keyword, String statement) {
this.keyword = keyword;
this.statement = statement;
}

/**
* Execute user's "unmark" command and change the storage file accordingly.
* @param taskList The list containing tasks.
* @param ui dealing with interactions with the user.
* @param storage The storage file of tasks.
*/
public void execute(TaskList taskList, Ui ui, Storage storage) {
ArrayList<Task> tasks = taskList.getTasks();
tryUnmarkTask(tasks, statement);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/duke/exception/DukeException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package duke.exception;


/**
* Exceptions specific to Duke.
*/
public class DukeException extends Exception{
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/duke/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ public class Parser {

private static String keyword;
private static String statement;

/**
* Parse the user's input into formatted command.
* @param fullCommand a single user's command line.
*/
public static Command parse(String fullCommand) throws DukeException {
fullCommand = fullCommand.trim();
if (countWithSplit(fullCommand) == 0) throw new DukeException();
Expand Down

0 comments on commit d95c806

Please sign in to comment.