Skip to content

Commit

Permalink
Fix bug for view lesson command
Browse files Browse the repository at this point in the history
  • Loading branch information
Nijnxw committed Oct 8, 2020
1 parent 7267584 commit 3bef6a6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private String getMessage(Model model) {
@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.updateFilteredGroupList(grpPredicate);
model.updateFilteredLessonList(lsnPredicate);
return new CommandResult(this.getMessage(model));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ public ViewLsnCommand parse(String args) throws ParseException {
private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) {
return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent());
}

}
10 changes: 5 additions & 5 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs
filteredGroups = new FilteredList<>(this.serenity.getGroupList());
students = new ArrayObservableList<>(new UniqueStudentList().asUnmodifiableObservableList());
lessons = new ArrayObservableList<>(new UniqueLessonList().asUnmodifiableObservableList());
filteredLessons = new FilteredList<>(new UniqueLessonList().asUnmodifiableObservableList());
filteredLessons = new FilteredList<>(lessons);
studentsInfo = new ArrayObservableList<>(new UniqueStudentInfoList().asUnmodifiableObservableList());
}

Expand All @@ -79,7 +79,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs
filteredGroups = new FilteredList<>(this.serenity.getGroupList());
students = new ArrayObservableList<>(new UniqueStudentList().asUnmodifiableObservableList());
lessons = new ArrayObservableList<>(new UniqueLessonList().asUnmodifiableObservableList());
filteredLessons = new FilteredList<>(new UniqueLessonList().asUnmodifiableObservableList());
filteredLessons = new FilteredList<>(lessons);
studentsInfo = new ArrayObservableList<>(new UniqueStudentInfoList().asUnmodifiableObservableList());
}

Expand Down Expand Up @@ -223,8 +223,8 @@ public void updateFilteredLessonList(Predicate<Lesson> predicate) {

@Override
public void updateStudentInfoList() {
if (!filteredGroups.isEmpty() || !lessons.isEmpty()) {
this.studentsInfo.setAll(this.lessons.get(0).getStudentsInfoAsUnmodifiableObservableList());
if (!filteredGroups.isEmpty() || !filteredLessons.isEmpty()) {
this.studentsInfo.setAll(this.filteredLessons.get(0).getStudentsInfoAsUnmodifiableObservableList());
}
}

Expand All @@ -245,7 +245,7 @@ public ObservableList<Lesson> getLessonList() {

@Override
public ObservableList<Lesson> getFilteredLessonList() {
return lessons;
return filteredLessons;
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/group/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public int hashCode() {

@Override
public String toString() {
return name + "," + students.toString();
return String.format("Group %s", name);
}

}
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/model/group/Lesson.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,10 @@ public boolean equals(Object obj) {
return otherClass.getName().equals(getName())
&& otherClass.getStudentsInfo().equals(getStudentsInfo());
}

@Override
public String toString() {
return String.format("Lesson %s", name);
}
}

0 comments on commit 3bef6a6

Please sign in to comment.