From cee040b74dd3c38f96cddb14a1b785c96204e871 Mon Sep 17 00:00:00 2001 From: gachia Date: Wed, 4 Sep 2019 17:02:23 +0800 Subject: [PATCH] Cleaned code with Checkstyle Used checkstyle to clean up coding style violations. --- src/main/java/FindCommand.java | 7 ++++--- src/main/java/Task.java | 2 +- src/main/java/TaskList.java | 13 ++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/FindCommand.java b/src/main/java/FindCommand.java index 1992ff3cab..0e4028c3f8 100644 --- a/src/main/java/FindCommand.java +++ b/src/main/java/FindCommand.java @@ -9,15 +9,16 @@ public class FindCommand extends Command { * description matches the search term. The method will output all Tasks that * contain the search term in the description. It will throw an exception if * the search term is empty. + * * @param storage Storage object for saving purposes - * @param tasks Contains the list of tasks - * @param ui Holds Ui printing method and user input field + * @param tasks Contains the list of tasks + * @param ui Holds Ui printing method and user input field * @throws DukeException If searchTerm is empty */ @Override public void execute(Storage storage, TaskList tasks, Ui ui) throws DukeException { String searchTerm = ui.readDesc().trim(); - if(searchTerm.isEmpty()){ + if (searchTerm.isEmpty()) { throw new DukeException("Search term cannot be blank."); } tasks.searchTaskList(searchTerm); diff --git a/src/main/java/Task.java b/src/main/java/Task.java index fed4b909c1..671d6eb362 100644 --- a/src/main/java/Task.java +++ b/src/main/java/Task.java @@ -57,7 +57,7 @@ public boolean getIsDone() { } /** - * Returns the Task's description + * Returns the Task's description. * @return description of Task */ public String getDescription() { diff --git a/src/main/java/TaskList.java b/src/main/java/TaskList.java index bc01905d52..a2a9d33223 100644 --- a/src/main/java/TaskList.java +++ b/src/main/java/TaskList.java @@ -16,6 +16,7 @@ public TaskList() { /** * Constructor to take in a populated ArrayList of Task type (i.e. from text file). + * * @param list ArrayList of Task Type */ public TaskList(ArrayList list) { @@ -24,6 +25,7 @@ public TaskList(ArrayList list) { /** * Adds a Task object into the list. + * * @param task A Task object */ public void addTask(Task task) { @@ -34,6 +36,7 @@ public void addTask(Task task) { /** * Deletes a Task from the list. + * * @param deleteIndex Index of selected Task Object, 1-based index */ public void deleteTask(int deleteIndex) { @@ -44,6 +47,7 @@ public void deleteTask(int deleteIndex) { /** * Returns selected Task object from list. + * * @param taskIndex Index of selected Task object, 1-based index * @return Task object */ @@ -62,14 +66,15 @@ public void showTaskList() { } /** - * Prints out the Tasks whose description matches the search term + * Prints out the Tasks whose description matches the search term. + * * @param searchTerm Keyword by user for search */ public void searchTaskList(String searchTerm) { System.out.println("Here are the matching tasks in your list:"); int noOfSearches = 1; - for(int i = 0; i < list.size(); i++){ - if(list.get(i).getDescription().contains(searchTerm)){ + for (int i = 0; i < list.size(); i++) { + if (list.get(i).getDescription().contains(searchTerm)) { System.out.println((noOfSearches) + "." + list.get(i)); noOfSearches += 1; } @@ -78,6 +83,7 @@ public void searchTaskList(String searchTerm) { /** * Sets boolean variable isDone of selected Task object to true. + * * @param doneIndex Index of selected Task object, 1-based index */ public void setDoneTask(int doneIndex) { @@ -88,6 +94,7 @@ public void setDoneTask(int doneIndex) { /** * Returns the list of tasks that Duke holds as an object. + * * @return ArrayList of Task type */ public ArrayList getTaskList() {