Skip to content

Commit 99adc01

Browse files
authored
Merge pull request nus-cs2103-AY2021S1#79 from khor-jingqian/find-and-list-routine
Find and list Routine
2 parents 698fe25 + 98dde3b commit 99adc01

File tree

17 files changed

+209
-10
lines changed

17 files changed

+209
-10
lines changed

docs/UserGuide.md

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
---
2+
layout: page
3+
title: User Guide
4+
---
5+
6+
7+
* Table of Contents
8+
{:toc}
9+
110
## 1. Introduction
211

312
fitNUS is tailored for **NUS students** that are interested in staying healthy and keeping fit. It is suitable for **all
@@ -137,12 +146,39 @@ Format: `routine_view INDEX`
137146
Examples:
138147
* `routine_view 2` Views routine with the index 2.
139148

149+
##### Before input:
150+
151+
![Routine View](./images/routine_view.png)
152+
153+
154+
#### After input:
155+
156+
![Routine View After](./images/routine_view_after.png)
157+
140158
#### 3.2.6 List routines : `routine_list`
141159

142160
Lists out all the routines in fitNUS.
143161

144162
Format: `routine_list`
145163

164+
![Routine List](./images/routine_list.png)
165+
166+
#### 3.2.7 Find routines : `find_routines`
167+
168+
Finds all routines with matching keyword given.
169+
170+
Format: `find_routines KEYWORD`
171+
172+
Example:
173+
* `find_routines upper` Finds all routines with the keyword "upper" in its name, regardless of uppercase or lowercase.
174+
175+
##### Input:
176+
![Find Routines](./images/routine_find.png)
177+
178+
##### Result:
179+
180+
![Find Routines Result](./images/routine_find_after.png)
181+
146182
### 3.3 Lesson
147183

148184
#### 3.3.1 Create new lesson : `lesson_add`
@@ -225,6 +261,10 @@ Deletes the routine or lesson scheduled on Monday, 1600-1800.
225261

226262
![Timetable Delete](./images/timetable_delete.png)
227263

264+
### BMI
265+
266+
#### Add or edit height : `height`
267+
228268
#### 3.4.4 View timetable : `timetable_view`
229269

230270
Views the timetable in fitNUS.
@@ -297,27 +337,50 @@ _{explain the feature here}_
297337

298338
## 4. Command summary
299339

340+
### 4.1 Miscellaneous
341+
342+
Action | Format |
343+
--------|-------|
344+
**Link to User Guide** | `help`
345+
**Save and exit fitNUS** | `exit`
346+
347+
### 4.2 Exercise
300348
Action | Format | Examples
301349
--------|-------|-----------
302-
**Link to User Guide** | `help`
303350
**Create Exercise** | `exercise_add n/EXERCISE_NAME [t/TAG]` | `exercise_add n/Bench Press t/Upper`
304351
**Delete Exercise** | `exercise_delete INDEX` | `exercise_delete 1`
305-
**List Exercises** | `list_exercises`
306352
**Find Exercises** | `find_exercises KEYWORD [MORE_KEYWORDS]` | `find_exercises Bench Press`
353+
**List Exercises** | `list_exercises`
354+
355+
### 4.3 Routine
356+
Action | Format | Examples
357+
--------|-------|-----------
307358
**Create Routine** | `routine_create r/ROUTINE_NAME` | `routine_create r/Leg Day Session`
308359
**Delete Routine** | `routine_delete INDEX` | `routine delete 10`
360+
**View Routine details** | `routine view INDEX` | `routine view 2`
309361
**Add Exercise to Routine** | `routine_add r/NAME_OF_TARGET_ROUTINE e/EXERCISE_NAME` | `routine_add r/Leg Day Session e/Squats`
310362
**Delete Exercise from Routine** | `routine_delete_exercise r/NAME_OF_TARGET_ROUTINE e/EXERCISE_NAME` | `routine_delete_exercise r/Leg Day Session e/Squats`
311-
**View Routine details** | `routine view INDEX` | `routine view 2`
312363
**List Routines** | `routine list`
364+
365+
### 4.4 Lesson
366+
Action | Format | Examples
367+
--------|-------|-----------
313368
**Create Lesson** | `lesson_add n/EXERCISE_NAME [t/TAG]` | `lesson_add n/CS2100 t/Thursday t/0900 t/1hours`
314369
**Delete Lesson** | `lesson_delete INDEX` | `lesson_delete 1`
315370
**List Lessons** | `list_lessons`
316371
**Find Lessons** | `find_lessons KEYWORD [MORE_KEYWORDS]` | `find_lessons CS2103T`
372+
373+
### 4.5 Timetable
374+
Action | Format | Examples
375+
--------|-------|-----------
317376
**Add Routine to Timetable** | `timetable_add_routine r/ROUTINE_NAME d/DAY_OF_THE_WEEK T/TIMING` | `timetable_add_routine add r/Leg Day Session d/Monday T/1600-1800`
318377
**Add Lesson to Timetable** | `timetable_add_lesson n/LESSON_NAME d/DAY_OF_THE_WEEK T/TIMING` | `timetable_add_lesson n/CS2103T d/Monday T/1200-1400`
319378
**Delete Routine or Lesson from Timetable** | `timetable_delete d/DAY_OF_THE_WEEK T/TIMING` | `timetable_delete d/Monday T/1600-1800`
320379
**View timetable** | `timetable view`
380+
381+
### 4.6 BMI
382+
Action | Format | Examples
383+
--------|-------|-----------
321384
**Add or edit Height** | `height h/HEIGHT` | `height h/170`
322385
**Add or edit Weight** | `weight w/WEIGHT` | `weight w/70`
323386
**View BMI** | `bmi`

docs/images/routine_find.png

915 Bytes
Loading

docs/images/routine_find_after.png

11.4 KB
Loading

docs/images/routine_list.png

16.4 KB
Loading

docs/images/routine_view.png

16.8 KB
Loading

docs/images/routine_view_after.png

11.7 KB
Loading

src/main/java/seedu/address/commons/core/Messages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class Messages {
1111
public static final String MESSAGE_INVALID_EXERCISE_DISPLAYED_INDEX = "The exercise index provided is invalid";
1212
public static final String MESSAGE_INVALID_LESSON_DISPLAYED_INDEX = "The lesson index provided is invalid";
1313
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";
14+
public static final String MESSAGE_ROUTINES_LISTED_OVERVIEW = "%1$d routines listed!";
1415
public static final String MESSAGE_EXERCISES_LISTED_OVERVIEW = "%1$d exercises listed!";
1516
public static final String MESSAGE_LESSONS_LISTED_OVERVIEW = "%1$d lessons listed!";
1617
public static final String MESSAGE_INVALID_ROUTINE_DISPLAYED_INDEX = "The routine index provided is invalid";
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package seedu.address.logic.commands.routines;
2+
3+
import static java.util.Objects.requireNonNull;
4+
5+
import seedu.address.commons.core.Messages;
6+
import seedu.address.logic.commands.Command;
7+
import seedu.address.logic.commands.CommandResult;
8+
import seedu.address.model.Model;
9+
import seedu.address.model.person.RoutineNameContainsKeywordsPredicate;
10+
11+
/**
12+
* Finds and lists all routines in fitNUS whose name contains any of the argument keywords.
13+
* Keyword matching is case insensitive.
14+
*/
15+
public class FindRoutinesCommand extends Command {
16+
17+
public static final String COMMAND_WORD = "find_routines";
18+
19+
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all routines whose names contain any of "
20+
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
21+
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
22+
+ "Example: " + COMMAND_WORD + " Lower";
23+
24+
private final RoutineNameContainsKeywordsPredicate predicate;
25+
26+
public FindRoutinesCommand(RoutineNameContainsKeywordsPredicate predicate) {
27+
this.predicate = predicate;
28+
}
29+
30+
@Override
31+
public CommandResult execute(Model model) {
32+
requireNonNull(model);
33+
model.updateFilteredRoutineList(predicate);
34+
return new CommandResult(
35+
String.format(Messages.MESSAGE_ROUTINES_LISTED_OVERVIEW, model.getFilteredRoutineList().size()));
36+
}
37+
38+
@Override
39+
public boolean equals(Object other) {
40+
return other == this // short circuit if same object
41+
|| (other instanceof FindRoutinesCommand // instanceof handles nulls
42+
&& predicate.equals(((FindRoutinesCommand) other).predicate)); // state check
43+
}
44+
}

src/main/java/seedu/address/logic/commands/routines/RoutineListCommand.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
public class RoutineListCommand extends Command {
1313

14-
public static final String COMMAND_WORD = "routine_list";
14+
public static final String COMMAND_WORD = "list_routines";
1515

1616
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Shows all routines in fitNUS.\n"
1717
+ "Example: " + COMMAND_WORD;
@@ -21,10 +21,7 @@ public class RoutineListCommand extends Command {
2121
@Override
2222
public CommandResult execute(Model model) {
2323

24-
String routineList = model.listRoutines();
25-
model.updateFilteredExerciseList(unused -> false);
26-
model.updateFilteredPersonList(unused -> false);
2724
model.updateFilteredRoutineList(PREDICATE_SHOW_ALL_ROUTINES);
28-
return new CommandResult(SHOWING_LIST_MESSAGE + "\n" + routineList);
25+
return new CommandResult(SHOWING_LIST_MESSAGE);
2926
}
3027
}

src/main/java/seedu/address/logic/commands/routines/RoutineViewCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class RoutineViewCommand extends Command {
2525
+ "Example: " + COMMAND_WORD + " "
2626
+ "3 ";
2727

28-
public static final String MESSAGE_SUCCESS = "Routine requested: %1$s";
28+
public static final String MESSAGE_SUCCESS = "Routine requested:";
2929
public static final String MESSAGE_OUT_OF_BOUNDS_ROUTINE = "This routine index is out of bounds!";
3030

3131
private final Index toView;
@@ -48,7 +48,8 @@ public CommandResult execute(Model model) throws CommandException {
4848
}
4949

5050
Routine routineToView = lastShownList.get(toView.getZeroBased());
51-
return new CommandResult(String.format(MESSAGE_SUCCESS, routineToView));
51+
model.viewRoutine(routineToView);
52+
return new CommandResult(String.format(MESSAGE_SUCCESS));
5253
}
5354

5455
@Override

0 commit comments

Comments
 (0)