Skip to content

Commit

Permalink
update javadoc code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
rexkoh425 committed Oct 9, 2024
1 parent 07ca1f9 commit 7cfb026
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/main/java/thethinker/command/TheThinker.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* Class which contains the main function.
* Loads file , polls for user input till bye command is received
* Loads file , polls for user input till bye command is received.
* If default file and user's newly input file is not valid , program ends.
*/
public class TheThinker{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package thethinker.exceptions;

/**
* This exception is thrown whenever there are formatting errors in the command given by the user
* This exception is thrown whenever there are formatting errors in the command given by the user.
*/
public class FormattingException extends Exception{

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/thethinker/file/FileLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.io.IOException;

/**
* Handles file loading operations when at the start of program
* Handles file loading operations when at the start of program.
*/
public class FileLoader {

Expand All @@ -16,7 +16,7 @@ public class FileLoader {

/**
* Loads default filepath and check if it exists.
* If file does not exist , create a new file based on user input
* If file does not exist , create a new file based on user input.
*
* @throws FileNotFoundException If file creation failed.
*/
Expand Down Expand Up @@ -95,7 +95,7 @@ private static void createFolder(File directoryName) {
}

/**
* Get user input on whether they want to save task to a file
* Gets user input on whether they want to save task to a file.
*/
public static boolean shouldSaveTask() {
UiControl.printSeparation();
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/thethinker/file/NewFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public boolean isFileExist() {
}

/**
* Read content of a file and adds all task to current task list.
* Reads content of a file and adds all task to current task list.
*
* @throws FileNotFoundException If the filepath is invalid.
*/
Expand Down Expand Up @@ -87,6 +87,8 @@ private void addTaskAccordingToFileData(String[] parameters) {
}

/**
* Writes all the task to the specified file.
*
* @throws IOException If the filepath is invalid.
*/
public void writeTaskListToFile() throws IOException {
Expand All @@ -97,7 +99,7 @@ public void writeTaskListToFile() throws IOException {
}

/**
* Converts task list into a load file format
* Converts task list into a load file format.
* If TaskList is empty , an empty string will be returned.
*
* @return A single string of task list in file format.
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/thethinker/parser/DateParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private static String toString(String date) {
* Converts date from format of dd/MM/yyyy HHmm to dd MMMM yyyy , h a.
* If date is not of dd/MM/yyyy HHmm format, the original string is returned.
*
* @param date deadline of task extracted from user input
* @param date deadline of task extracted from user input.
* @return date of string type with format e.g. 15 October 2019 , 6 pm.
*
*/
Expand Down Expand Up @@ -66,9 +66,9 @@ private static int isValidDay(String day) {
}

/**
* Compares date according to the deadline of each task types.
* Checks if date matches according to the deadline of each task types.
*
* @param task Task to compare
* @param task Task to compare.
* @param specifiedDate date in format of dd/MM/yyyy.
*/
public static boolean isMatchingDateByType(Task task , String specifiedDate) {
Expand All @@ -95,8 +95,10 @@ private static DateTimeFormatter getDateFormat(String date) {
}

/**
* @param taskDate Deadline corresponding to the task
* @param specifiedDate Queried date in any format
* Checks if the user given date and task date matches.
*
* @param taskDate Deadline corresponding to the task.
* @param specifiedDate Queried date in any format.
*/
private static boolean isMatchingDate(String taskDate , String specifiedDate) {

Expand Down Expand Up @@ -155,10 +157,10 @@ private static boolean isResultDateTimeFormat(String dateStr) {
}

/**
* Parse date after get command and checks if queried date is of dd/mm/yyyy format
* Parses date after get command and checks if queried date is of dd/mm/yyyy format.
*
* @return date in dd/MM/yyyy format
* @throws FormattingException If date is missing or in the wrong format(i.e. not dd/mm/yyyy)
* @return date in dd/MM/yyyy format.
* @throws FormattingException If date is missing or in the wrong format(i.e. not dd/mm/yyyy).
*/
public static String parseDateAfterGet() throws FormattingException {
final int LENGTH_OF_GET = 3;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/thethinker/parser/DeadlineParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class DeadlineParser extends UserInputParser{
public static final String DEADLINE_FORMAT = "Please follow format : deadline [task] /by [time]";

/**
* Parse user input based on the format of Deadline and create Deadline object.
* Parses user input based on the format of Deadline and create Deadline object.
*
* @throws FormattingException If /by , task description , deadline is missing from user input
* @throws FormattingException If /by , task description , deadline is missing from user input.
*/
public static Deadline parseDeadline() throws FormattingException {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/thethinker/parser/EventParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public class EventParser extends UserInputParser{
public static final String EVENT_FORMAT = "Please follow format : event [task] /from [start time] /to [end time]";

/**
* Parse user input based on the format of Event and use the result to create Event object.
* Parses user input based on the format of Event and use the result to create Event object.
*
* @throws FormattingException If /from , /to , task description , start time and end time
* is missing from user input. If /to is in front of /from.
* @throws FormattingException If /from, /to, task description, start and end time is missing from user input.
* If /to is in front of /from.
*/
public static Event parseEvent() throws FormattingException {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/thethinker/parser/TodoParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class TodoParser extends UserInputParser{
public static final String TODO_FORMAT = "Please follow format : todo [task]";

/**
* Parse user input based on the format of To-do and create To-do object
* Parses user input based on the format of To-do and create To-do object.
*
* @throws FormattingException if task description is not provided in user input
* @throws FormattingException if task description is not provided in user input.
*/
public static Task parseTodo() throws FormattingException {

Expand Down
12 changes: 7 additions & 5 deletions src/main/java/thethinker/parser/UserInputParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* Handles the parsing of input other than to-do , deadline , event and date related parsing.
* Parsing of To-do , deadline , event and date are done by their respective parsers
* Parsing of To-do , deadline , event and date are done by their respective parsers.
*/
public class UserInputParser {

Expand All @@ -26,9 +26,9 @@ public static String parseUserAction() {
}

/**
* Used to obtain task number after inputting commands that require task number
* Obtains task number after inputting commands that require task number.
*
* @return Task number
* @return Task number.
* @throws NumberFormatException If task number string provided is not a number.
* @throws FormattingException If no task or multiple task number is provided.
*/
Expand All @@ -51,8 +51,10 @@ public static int parseNumberAfterTask(String task) throws NumberFormatException
}

/**
* @return keyword after removing space on the side
* @throws FormattingException If no keyword is provided or keyword is more than one word
* Extracts single word from user input after "find".
*
* @return keyword after removing space on the side.
* @throws FormattingException If no keyword is provided or keyword is more than one word.
*/
public static String parseKeywordAfterFind() throws FormattingException {

Expand Down
37 changes: 31 additions & 6 deletions src/main/java/thethinker/tasks/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ public static void addTask(Task task) {
}

/**
* Adds task to task list without printing any information to the console compared to addTask()
* Adds task to task list without printing any information to the console.
*/
public static void addTaskWithoutResponse(Task task) {
listOfTasks.add(task);
listLength++;
}

public static void deleteTask(int taskNumber) {
/**
* Deletes task from current task list.
*
* @throws IndexOutOfBoundsException If number given is more than task list length.
*/
public static void deleteTask(int taskNumber) throws IndexOutOfBoundsException{

Task taskToRemove = listOfTasks.get(taskNumber-1);
listLength--;
Expand All @@ -35,15 +40,25 @@ public static void deleteTask(int taskNumber) {
System.out.printf("Now you have %d tasks in the list.\n" , listLength);
}

public static void setAsDone(int listNumber) throws IndexOutOfBoundsException {
Task currentTask = listOfTasks.get(listNumber-1);
/**
* Marks task from current task list.
*
* @throws IndexOutOfBoundsException If number given is more than task list length.
*/
public static void setAsDone(int taskNumber) throws IndexOutOfBoundsException {
Task currentTask = listOfTasks.get(taskNumber-1);
System.out.println("Nice! I've marked this task as done:");
System.out.printf(" [%c][X] " + currentTask.getTaskDescription() + "\n" , currentTask.getTaskType());
currentTask.setMarkedAsDone(true);
}

public static void setAsNotDone(int listNumber) throws IndexOutOfBoundsException {
Task currentTask = listOfTasks.get(listNumber-1);
/**
* Unmarks task from current task list.
*
* @throws IndexOutOfBoundsException If number given is more than task list length.
*/
public static void setAsNotDone(int taskNumber) throws IndexOutOfBoundsException {
Task currentTask = listOfTasks.get(taskNumber-1);
System.out.println("OK, I've marked this task as not done yet:");
System.out.printf(" [%c][ ] " + currentTask.getTaskDescription() + "\n" , currentTask.getTaskType());
currentTask.setMarkedAsDone(false);
Expand All @@ -57,6 +72,11 @@ public static void listTasks() {
}
}

/**
* Lists all the task with deadline same as date given.
*
* @param date should be dd/MM/yyyy format.
*/
public static void listTasksOfDate(String date){
System.out.println("Here are the tasks in your list in " + date + " :");
int counter = 0;
Expand All @@ -74,6 +94,11 @@ public static void listTasksOfDate(String date){
}
}

/**
* Lists all the task in Task List which contains the keyword.
*
* @param keyword one single word only.
*/
public static void listTasksOfKeyword(String keyword) {

System.out.println("Here are the matching tasks in your list:");
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/thethinker/ui/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
public interface CommandLine {

/**
* Checks for user input and do corresponding command
* and write task to file till bye command.
* Checks for user input and do corresponding command.
* Write task to file till bye command.
*/
static void pollForUserInputTillBye(boolean isWriteTask) {
String userAction;
Expand All @@ -33,7 +33,7 @@ static void pollForUserInputTillBye(boolean isWriteTask) {
/**
* Checks for user input and do corresponding command and write task to file.
*
* @return the original trimmed user action
* @return the original trimmed user action.
*/
private static String getUserActionAndDoTask() {
String userInput = UserInputParser.getUserInput();
Expand All @@ -43,7 +43,7 @@ private static String getUserActionAndDoTask() {
}

/**
* Do corresponding actions depending on the command by the user.
* Selects task to do according to the command by the user.
*
* @param userAction the first word of the user input.
*/
Expand Down

0 comments on commit 7cfb026

Please sign in to comment.