Skip to content

Commit aebdf38

Browse files
committed
Merge branch 'master' into change-design
2 parents 7ae6bc3 + 5275d7d commit aebdf38

31 files changed

Lines changed: 622 additions & 22 deletions

docs/DeveloperGuide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
263263
| `* * *` | student who has no knowledge of working out|view what exercise routines the application has|choose the right one for me
264264
| `* * *` | busy student | add workout routines into my schedule | have the time to exercise
265265
| `* * *` | student | delete a workout routine | keep my schedule up-to-date
266-
| `* * *` | NUS student | see my timetable | slot in my workout sessions with ease
266+
| `* * *` | NUS student | see my timetable | slot in my workout sessions with ease
267267

268268
*{More to be added}*
269269

@@ -293,7 +293,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
293293
* 3a1. AddressBook shows an error message.
294294

295295
Use case resumes at step 2.
296-
296+
297297
**Use case: Create a new routine**
298298

299299
**MSS**
@@ -312,7 +312,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
312312
* 3a1. fitNUS shows an error message.
313313

314314
Use case resumes at step 2.
315-
315+
316316
**Use case: Delete a routine**
317317

318318
**MSS**

docs/UserGuide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fitNUS is **optimized for use via a Command Line Interface** (CLI) while still
1616

1717
--------------------------------------------------------------------------------------------------------------------
1818
<a name="quick-start"></a>
19-
## Quick start
19+
## Quick start
2020

2121
1. Ensure you have Java `11` or above installed in your Computer.
2222

src/main/java/seedu/address/logic/Logic.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import seedu.address.model.person.Lesson;
1313
import seedu.address.model.person.Person;
1414
import seedu.address.model.person.Routine;
15+
import seedu.address.model.person.Slot;
1516

1617
/**
1718
* API of the Logic component
@@ -45,6 +46,9 @@ public interface Logic {
4546
/** Returns an unmodifiable view of the filtered list of lessons */
4647
ObservableList<Lesson> getFilteredLessonList();
4748

49+
/** Returns an unmodifiable view of the filtered list of slots */
50+
ObservableList<Slot> getFilteredSlotList();
51+
4852
/**
4953
* Returns the user prefs' address book file path.
5054
*/

src/main/java/seedu/address/logic/LogicManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import seedu.address.model.person.Lesson;
1919
import seedu.address.model.person.Person;
2020
import seedu.address.model.person.Routine;
21+
import seedu.address.model.person.Slot;
2122
import seedu.address.storage.Storage;
2223

2324
/**
@@ -77,10 +78,16 @@ public ObservableList<Routine> getFilteredRoutineList() {
7778
return model.getFilteredRoutineList();
7879
}
7980

81+
@Override
8082
public ObservableList<Lesson> getFilteredLessonList() {
8183
return model.getFilteredLessonList();
8284
}
8385

86+
@Override
87+
public ObservableList<Slot> getFilteredSlotList() {
88+
return model.getFilteredSlotList();
89+
}
90+
8491
@Override
8592
public Path getAddressBookFilePath() {
8693
return model.getAddressBookFilePath();
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package seedu.address.logic.commands;
2+
3+
import static java.util.Objects.requireNonNull;
4+
5+
import seedu.address.commons.core.Messages;
6+
import seedu.address.model.Model;
7+
import seedu.address.model.person.LessonNameContainsKeywordsPredicate;
8+
9+
/**
10+
* Finds and lists all lessons in fitNUS whose name contains any of the argument keywords.
11+
* Keyword matching is case insensitive.
12+
*/
13+
public class FindLessonsCommand extends Command {
14+
15+
public static final String COMMAND_WORD = "find_lessons";
16+
17+
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all lessons whose names contain any of "
18+
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
19+
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
20+
+ "Example: " + COMMAND_WORD + " CS1231";
21+
22+
private final LessonNameContainsKeywordsPredicate predicate;
23+
24+
public FindLessonsCommand(LessonNameContainsKeywordsPredicate predicate) {
25+
this.predicate = predicate;
26+
}
27+
28+
@Override
29+
public CommandResult execute(Model model) {
30+
requireNonNull(model);
31+
model.updateFilteredLessonList(predicate);
32+
return new CommandResult(
33+
String.format(Messages.MESSAGE_LESSONS_LISTED_OVERVIEW, model.getFilteredLessonList().size()));
34+
}
35+
36+
@Override
37+
public boolean equals(Object other) {
38+
return other == this // short circuit if same object
39+
|| (other instanceof FindLessonsCommand // instanceof handles nulls
40+
&& predicate.equals(((FindLessonsCommand) other).predicate)); // state check
41+
}
42+
}

src/main/java/seedu/address/logic/commands/TimetableAddLessonCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class TimetableAddLessonCommand extends Command {
2020
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a Lesson to the timetable in fitNUS. "
2121
+ "Parameters: "
2222
+ PREFIX_NAME + "LESSON_NAME "
23-
+ PREFIX_DAY + "DAY"
23+
+ PREFIX_DAY + "DAY "
2424
+ PREFIX_TIME + "TIME"
2525
+ "\n"
2626
+ "Example: " + COMMAND_WORD + " "

src/main/java/seedu/address/logic/commands/TimetableAddRoutineCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class TimetableAddRoutineCommand extends Command {
1919
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a Routine to the timetable in fitNUS. "
2020
+ "Parameters: "
2121
+ PREFIX_ROUTINE + "ROUTINE_NAME "
22-
+ PREFIX_DAY + "DAY"
22+
+ PREFIX_DAY + "DAY "
2323
+ PREFIX_TIME + "TIME"
2424
+ "\n"
2525
+ "Example: " + COMMAND_WORD + " "

src/main/java/seedu/address/logic/commands/TimetableDeleteSlotCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class TimetableDeleteSlotCommand extends Command {
1919

2020
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Deletes the slot identified by its day and time.\n"
2121
+ "Parameters: "
22-
+ PREFIX_DAY + "DAY"
22+
+ PREFIX_DAY + "DAY "
2323
+ PREFIX_TIME + "TIME"
2424
+ "\n"
2525
+ "Example: " + COMMAND_WORD + " "

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import seedu.address.model.Model;
1111
import seedu.address.model.person.Exercise;
1212
import seedu.address.model.person.Routine;
13+
import seedu.address.model.person.exceptions.DuplicateExerciseException;
1314

1415
/**
1516
* Adds an Routine to fitNUS.
@@ -30,6 +31,8 @@ public class RoutineAddExerciseCommand extends Command {
3031
public static final String MESSAGE_SUCCESS = "Exercise added to Routine: %1$s";
3132
public static final String MESSAGE_MISSING_ROUTINE = "This routine does not exist in fitNUS";
3233
public static final String MESSAGE_MISSING_EXERCISE = "This exercise does not exist in fitNUS";
34+
public static final String MESSAGE_DUPLICATE_EXERCISE = "This exercise already exist in the routine!";
35+
3336

3437
private final Routine routineToAdd;
3538
private final Exercise exerciseToAdd;
@@ -53,8 +56,12 @@ public CommandResult execute(Model model) throws CommandException {
5356
throw new CommandException(MESSAGE_MISSING_EXERCISE);
5457
}
5558

56-
model.addExerciseToRoutine(routineToAdd, exerciseToAdd);
57-
return new CommandResult(String.format(String.format(MESSAGE_SUCCESS, routineToAdd), exerciseToAdd));
59+
try {
60+
model.addExerciseToRoutine(routineToAdd, exerciseToAdd);
61+
return new CommandResult(String.format(String.format(MESSAGE_SUCCESS, routineToAdd), exerciseToAdd));
62+
} catch (DuplicateExerciseException error) {
63+
throw new CommandException(MESSAGE_DUPLICATE_EXERCISE);
64+
}
5865
}
5966

6067
@Override
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package seedu.address.logic.commands.routines;
2+
3+
import static java.util.Objects.requireNonNull;
4+
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
5+
import static seedu.address.logic.parser.CliSyntax.PREFIX_ROUTINE;
6+
7+
import seedu.address.logic.commands.Command;
8+
import seedu.address.logic.commands.CommandResult;
9+
import seedu.address.logic.commands.exceptions.CommandException;
10+
import seedu.address.model.Model;
11+
import seedu.address.model.person.Exercise;
12+
import seedu.address.model.person.Routine;
13+
14+
/**
15+
* Deletes a routine identified using it's displayed index from fitNUS.
16+
*/
17+
public class RoutineDeleteExerciseCommand extends Command {
18+
19+
public static final String COMMAND_WORD = "routine_delete_exercise";
20+
21+
public static final String MESSAGE_USAGE = COMMAND_WORD
22+
+ ": Deletes the mentioned Exercise used in the specified Routine.\n"
23+
+ "Parameters: "
24+
+ PREFIX_ROUTINE + "ROUTINE_NAME "
25+
+ PREFIX_EMAIL + "EXERCISE_NAME"
26+
+ "\n"
27+
+ "Example: " + COMMAND_WORD + " "
28+
+ PREFIX_ROUTINE + "Leg Day Session "
29+
+ PREFIX_EMAIL + "Squats ";
30+
31+
public static final String MESSAGE_DELETE_EXERCISE_SUCCESS = "Deleted Exercise from Routine: %1$s";
32+
public static final String MESSAGE_MISSING_ROUTINE = "Deleted Exercise from Routine: %1$s";
33+
public static final String MESSAGE_MISSING_EXERCISE = "Deleted Exercise from Routine: %1$s";
34+
35+
private final Routine routine;
36+
private final Exercise exercise;
37+
38+
/**
39+
* Creates a RoutineDeleteExericseCommand object.
40+
* @param routine Specified Routine that the user wants to delete an Exercise from.
41+
* @param exercise Specified Exercise that the user wants to delete.
42+
*/
43+
public RoutineDeleteExerciseCommand(Routine routine, Exercise exercise) {
44+
this.routine = routine;
45+
this.exercise = exercise;
46+
}
47+
48+
@Override
49+
public CommandResult execute(Model model) throws CommandException {
50+
requireNonNull(model);
51+
52+
if (!model.hasRoutine(routine)) {
53+
throw new CommandException(MESSAGE_MISSING_ROUTINE);
54+
} else if (!model.hasExercise(exercise)) {
55+
throw new CommandException(MESSAGE_MISSING_EXERCISE);
56+
}
57+
58+
model.deleteExerciseToRoutine(routine, exercise);
59+
return new CommandResult(String.format(String.format(MESSAGE_DELETE_EXERCISE_SUCCESS,
60+
routine), exercise));
61+
}
62+
63+
@Override
64+
public boolean equals(Object other) {
65+
return other == this // short circuit if same object
66+
|| (other instanceof RoutineDeleteExerciseCommand // instanceof handles nulls
67+
&& exercise.equals(((RoutineDeleteExerciseCommand) other).exercise) // state check
68+
&& routine.equals(((RoutineDeleteExerciseCommand) other).routine)); // state check
69+
}
70+
}

0 commit comments

Comments
 (0)