Skip to content

Commit

Permalink
Merge pull request #92 from muhammad-khair/branch-add-lessons-to-ui
Browse files Browse the repository at this point in the history
Add Lessons to UI
  • Loading branch information
Timothyoung97 committed Oct 8, 2021
2 parents 906389e + ca26b1a commit b69c766
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
Binary file modified docs/images/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/UserPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class UserPrefs implements ReadOnlyUserPrefs {

private GuiSettings guiSettings = new GuiSettings();
private Path addressBookFilePath = Paths.get("data" , "addressbook.json");
private Path addressBookFilePath = Paths.get("data" , "tuitione.json");

/**
* Creates a {@code UserPrefs} with default values.
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/seedu/address/model/lesson/Lesson.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,20 @@ public boolean isAbleToEnroll(Student student) {
}

/**
* Returns true if the lessons overlap in timing.
* Returns true if the lessons overlap in timing and day.
*/
public boolean hasOverlappedTiming(Lesson otherLesson) {
LocalTime otherStartTime = otherLesson.getStartTime();
LocalTime otherEndTime = otherLesson.getEndTime();
return (otherStartTime.isAfter(startTime) && otherStartTime.isBefore(endTime))
|| (otherEndTime.isAfter(startTime) && otherEndTime.isBefore(endTime));

boolean isClashingStartTime = (otherStartTime.isAfter(startTime) && otherStartTime.isBefore(endTime));
boolean isClashingEndTime = (otherEndTime.isAfter(startTime) && otherEndTime.isBefore(endTime));
boolean isOnSameDay = otherLesson.getDayOfWeek().equals(dayOfWeek);

if (!isOnSameDay) {
return false;
}
return (isClashingStartTime || isClashingEndTime);
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.address.model.lesson.Lesson;
import seedu.address.model.person.Student;

/**
Expand Down Expand Up @@ -42,6 +43,8 @@ public class PersonCard extends UiPart<Region> {
private Label grade;
@FXML
private FlowPane tags;
@FXML
private Label lessons;

/**
* Creates a {@code PersonCode} with the given {@code Person} and index to display.
Expand All @@ -58,6 +61,10 @@ public PersonCard(Student student, int displayedIndex) {
student.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
lessons.setText(student.getLessons().stream()
.sorted(Comparator.comparing(Lesson::getLessonCode))
.map(Lesson::getLessonCode)
.reduce("Lesson(s): ", (l1, l2) -> l1 + '\t' + l2));
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/view/PersonListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<Label fx:id="parentContact" styleClass="cell_small_label" text="\$parentContact" />
<Label fx:id="address" styleClass="cell_small_label" text="\$address" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
<Label fx:id="lessons" styleClass="cell_small_label" text="\$lessons" />
</VBox>
</GridPane>
</HBox>

0 comments on commit b69c766

Please sign in to comment.