@@ -55,7 +55,7 @@ public String add(Task task) {
5555
5656 String addTaskEndStr = addTaskEnd .insert (13 , this .internalList .size ()).toString ();
5757
58- assert this .internalList .size () > 0 : "task not added" ;
58+ assert this .internalList .size () > 0 : "task not added" ;
5959 return ECHO_ADD_TASK
6060 + task .toString ()
6161 + "\n "
@@ -68,7 +68,7 @@ public String add(Task task) {
6868 * @return response of the remove action.
6969 */
7070 public String remove (int position ) throws IllegalPositionException {
71- assert this .internalList .size () > 0 : "task list is empty, cannot delete" ;
71+ assert this .internalList .size () > 0 : "task list is empty, cannot delete" ;
7272
7373
7474 if (position < 0 || position >= internalList .size ()) {
@@ -93,7 +93,7 @@ public String remove(int position) throws IllegalPositionException {
9393 * @return response of the mark action.
9494 */
9595 public String markTaskAsDone (int position ) throws IllegalPositionException {
96- assert this .internalList .size () > 0 : "task list is empty, cannot mark" ;
96+ assert this .internalList .size () > 0 : "task list is empty, cannot mark" ;
9797
9898 if (position < 0 || position >= internalList .size ()) {
9999 throw new IllegalPositionException ("Oops!!! The input position "
@@ -108,13 +108,18 @@ public String markTaskAsDone(int position) throws IllegalPositionException {
108108 + "\n " ;
109109 }
110110
111+ /**
112+ * Filters tasks by checking whether the description contains a specific keyword.
113+ * @param keyWord user input keyword.
114+ * @return string representations of matched tasks.
115+ */
111116 public String findByKeyWord (String keyWord ) {
112117 StringBuilder matchedTasks = new StringBuilder ();
113118 matchedTasks .append (ECHO_FIND_TASK );
114119
115120 for (int i = 0 ; i < this .internalList .size (); i ++) {
116121 if (this .internalList .get (i ) == null ) {
117- assert false : "element in arraylist is null" ;
122+ assert false : "element in arraylist is null" ;
118123 continue ;
119124 }
120125 Task currentTask = this .internalList .get (i );
@@ -129,6 +134,11 @@ public String findByKeyWord(String keyWord) {
129134 return matchedTasks .toString ();
130135 }
131136
137+ /**
138+ * Filters tasks by date. Ignore todo tasks.
139+ * @param targetDate user input date.
140+ * @return string representation of matches tasks.
141+ */
132142 public String findTasksOnDate (LocalDate targetDate ) {
133143 StringBuilder tasksOnDate = new StringBuilder ();
134144 tasksOnDate .append (ECHO_VIEW_SCHEDULE );
@@ -138,7 +148,7 @@ public String findTasksOnDate(LocalDate targetDate) {
138148
139149 for (int i = 0 ; i < this .internalList .size (); i ++) {
140150 if (this .internalList .get (i ) == null ) {
141- assert false : "element in arraylist is null" ;
151+ assert false : "element in arraylist is null" ;
142152 continue ;
143153 }
144154 Task currentTask = this .internalList .get (i );
@@ -161,6 +171,10 @@ public int size() {
161171 return internalList .size ();
162172 }
163173
174+ public Task getTask (int index ) {
175+ return internalList .get (index );
176+ }
177+
164178 /**
165179 * Converts the task list to a string by looping through the tasks and concatenate
166180 * all the string representation of tasks.
@@ -170,7 +184,7 @@ public String toString() {
170184 StringBuilder listOverView = new StringBuilder (ECHO_VIEW_TASK_LIST );
171185 for (int i = 0 ; i < this .internalList .size (); i ++) {
172186 if (this .internalList .get (i ) == null ) {
173- assert false : "element in arraylist is null" ;
187+ assert false : "element in arraylist is null" ;
174188 continue ;
175189 }
176190 listOverView .append (Integer .toString (i + 1 ));
0 commit comments