Skip to content

Commit

Permalink
Add Javadoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ningtan11 committed Oct 11, 2022
1 parent 3b6d0ff commit dd3cf18
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 6 deletions.
19 changes: 16 additions & 3 deletions src/main/java/seedu/duke/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public static Command parse(String inputText) throws DukeException {
if (splitInput.length == 2 && COMMANDS.contains(splitInput[0])) {
String commandWord = splitInput[0];
String details = splitInput[1];
if (commandWord.equals("todo") ||
commandWord.equals("deadline") ||
commandWord.equals("event")) {
if (commandWord.equals("todo")
|| commandWord.equals("deadline")
|| commandWord.equals("event")) {
return addTaskParser(commandWord, details);

} else if (commandWord.equals("edit")) {
Expand Down Expand Up @@ -77,6 +77,13 @@ public static Command parse(String inputText) throws DukeException {
return null;
}

/**
* Separate method for parsing add task commands (todo, deadline or event)
* @param commandWord
* @param details
* @return
* @throws DukeException
*/
public static Command addTaskParser(String commandWord, String details) throws DukeException {
if (commandWord.equals("todo")) {
if (details.length() <= 1) {
Expand Down Expand Up @@ -113,6 +120,12 @@ public static Command addTaskParser(String commandWord, String details) throws D
}
}

/**
* Separate method for parsing 'edit' command
* @param details user input, omitting the 'edit' word
* @return
* @throws DukeException
*/
public static Command editParser(String details) throws DukeException {
String[] taskDesc = details.split(" ", 3);
int index;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/seedu/duke/command/CoffeeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@
import seedu.duke.exception.DukeException;
import seedu.duke.list.TaskList;

/**
* Class for executing Coffee command
*/
public class CoffeeCommand extends Command {
public CoffeeCommand() {
super();
}

/**
* Makes the user a cup of coffee
* @param list
* @return
* @throws DukeException
*/
@Override
public String execute(TaskList list) throws DukeException {
return Ui.makeCoffee();
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/seedu/duke/command/EditNameCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import seedu.duke.ui.Ui;
import seedu.duke.task.Task;

/**
* Class for executing edit name command
*/
public class EditNameCommand extends Command {
private int index;
private String desc;
Expand All @@ -15,6 +18,12 @@ public EditNameCommand(int index, String desc) {
this.desc = desc;
}

/**
* Changes the name/description of the given task
* @param list
* @return
* @throws DukeException
*/
@Override
public String execute(TaskList list) throws DukeException {
int len = list.size();
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/seedu/duke/command/EditTimeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import seedu.duke.task.EventTask;
import seedu.duke.task.Task;

/**
* Class for executing Edit Time command
*/
public class EditTimeCommand extends Command {
private int index;
private String newTime;
Expand All @@ -17,6 +20,12 @@ public EditTimeCommand(int index, String newTime) {
this.newTime = newTime;
}

/**
* Changes the deadline/event time for the given task
* @param list
* @return
* @throws DukeException
*/
@Override
public String execute(TaskList list) throws DukeException {
int len = list.size();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package seedu.duke.exception;

/**
* Exception class to be used when insufficient arguments are inputed
*/
public class NotEnoughArgumentsException extends DukeException {
public NotEnoughArgumentsException() {
super("I'll need more information than that, please, Master.");
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/seedu/duke/exception/NotNumberException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package seedu.duke.exception;

/**
* Exception class to be used when format for certain commands is wrong
*/
public class NotNumberException extends DukeException {
public NotNumberException() {
super("Please input the index of the relevant task after the command word, Master.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package seedu.duke.exception;

/**
* Exception class to be used when the task index given does not exist
*/
public class TaskDoesNotExistException extends DukeException {

public TaskDoesNotExistException(int i) {
super("There is no task " + Integer.valueOf(i + 1) + " just yet, Master.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package seedu.duke.exception;

import seedu.duke.Duke;

/**
* Exception class to be used when too many arguments are inputted
*/
public class TooManyArgumentsException extends DukeException {
public TooManyArgumentsException(String command) {
super("Please input only '" + command + "' and a number, Master.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package seedu.duke.exception;

/**
* Exception class to be used when user input cannot be handled
*/
public class UnrecognisedCommandException extends DukeException {
public UnrecognisedCommandException() {
super("I'm sorry Master, I have not yet been trained to respond to that.");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/duke/task/DeadlineTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public DeadlineTask(String name, String date, boolean isDone) {
}
}

/**
* Changes the date
* @param date
*/
public void editTime(String date) {
try {
this.date = LocalDate.parse(date);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/duke/task/EventTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public EventTask(String name, String date, boolean isDone) {
}
}

/**
* Changes the date
* @param date
*/
public void editTime(String date) {
try {
this.date = LocalDate.parse(date);
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/seedu/duke/task/Task.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package seedu.duke.task;

/**
* General class for tasks
*/
public class Task {
String name;
boolean isDone;
Expand All @@ -10,12 +13,21 @@ public Task(String name) {
this.isDone = false;
}

/**
* Constructor for loading list
* @param name
* @param isDone
*/
public Task(String name, boolean isDone) {
this.name = name;
this.isDone = isDone;
}


/**
* Indicates if a task is done or not
* @return
*/
public String getStatus() {
if (isDone) {
return "[X]";
Expand All @@ -33,6 +45,10 @@ public String getName() {
}
public String getType() { return TYPE;};

/**
* Marks a task as done.
* @return true if successfully marked done, false if task is already done
*/
public boolean markDone() {
if (isDone) {
return false;
Expand All @@ -41,6 +57,10 @@ public boolean markDone() {
return true;
}

/**
* Marks a task as undone
* @return trust if successfully marked undone, false if task is already undone
*/
public boolean markUndone() {
if (!isDone) {
return false;
Expand All @@ -49,6 +69,10 @@ public boolean markUndone() {
return true;
}

/**
* Changes the name/description
* @param newName
*/
public void changeDesc(String newName) {
this.name = newName;
}
Expand Down

0 comments on commit dd3cf18

Please sign in to comment.