Skip to content

Commit

Permalink
Extract method of printTask
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoMinWei committed Sep 26, 2023
1 parent 89ee1b9 commit 77381f5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/neo/task/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ public static void printList() {

System.out.println("Here are the tasks in your list:");
for (Task task : list) {
System.out.print((listIndex) + ". ");
System.out.println(task);
printTask(task, listIndex);
listIndex++;
}
}

private static void printTask(Task task, int listIndex) {
System.out.print(listIndex + ". ");
System.out.println(task);
}

/**
* Decides if there is a match between the input string and the description of tasks in the list.
*
Expand Down Expand Up @@ -80,8 +84,7 @@ private static void printMatchingTasks(String toFind) {

for (Task task : list) {
if (task.description.contains(toFind) || toFind.contains(task.description)) {
System.out.print(listIndex + ". ");
System.out.println(task);
printTask(task, listIndex);
}
listIndex++;
}
Expand Down

0 comments on commit 77381f5

Please sign in to comment.