Skip to content

Commit

Permalink
Merge branch 'branch-A-Checkstyle'
Browse files Browse the repository at this point in the history
  • Loading branch information
gachia committed Sep 7, 2019
2 parents 8ba9c55 + cee040b commit a7bc606
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/main/java/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean getIsDone() {
}

/**
* Returns the Task's description
* Returns the Task's description.
* @return description of Task
*/
public String getDescription() {
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Task> list) {
Expand All @@ -24,6 +25,7 @@ public TaskList(ArrayList<Task> list) {

/**
* Adds a Task object into the list.
*
* @param task A Task object
*/
public void addTask(Task task) {
Expand All @@ -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) {
Expand All @@ -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
*/
Expand All @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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<Task> getTaskList() {
Expand Down

0 comments on commit a7bc606

Please sign in to comment.