Skip to content

Commit

Permalink
Fix tutorial group storage issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyiyang committed Nov 3, 2021
1 parent a27e6a3 commit 6a2743e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static GroupType parseGroupType(String groupType) throws ParseException {
if (!GroupType.isValidGroupType(groupType)) {
throw new ParseException(GroupType.MESSAGE_CONSTRAINTS);
}
return new GroupType(groupType);
return new GroupType(groupType.toUpperCase());
}

/**
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/seedu/address/model/Classmate.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class Classmate implements ReadOnlyClassmate {

private final UniqueStudentList students;
private final UniqueTutorialClassList tutorialClasses;
private final UniqueTutorialGroupList tutorialGroups;

/*
* The 'unusual' code block below is a non-static initialization block, sometimes used to avoid duplication
Expand All @@ -35,7 +34,6 @@ public class Classmate implements ReadOnlyClassmate {
{
students = new UniqueStudentList();
tutorialClasses = new UniqueTutorialClassList();
tutorialGroups = new UniqueTutorialGroupList();
}

public Classmate() {}
Expand Down Expand Up @@ -158,30 +156,30 @@ public void removeTutorialClass(TutorialClass key) {
* {@code key} must exist in the ClassMATE.
*/
public void removeTutorialGroup(TutorialGroup key) {
tutorialGroups.remove(key);
tutorialClasses.remove(key);
}

/**
* Returns true if a tutorialGroup with the same identity as {@code tutorialGroup} exists in the ClassMATE.
*/
public boolean hasTutorialGroup(TutorialGroup tutorialGroup) {
requireNonNull(tutorialGroup);
return tutorialGroups.contains(tutorialGroup);
return tutorialClasses.contains(tutorialGroup);
}

/**
* Adds a tutorialGroup to the ClassMATE.
* The tutorial group must not already exist in the ClassMATE.
*/
public void addTutorialGroup(TutorialGroup tutorialGroup) {
tutorialGroups.add(tutorialGroup);
tutorialClasses.add(tutorialGroup);
}

/**
* Sorts the tutorial groups in ClassMATE.
*/
public void sortTutorialGroups() {
tutorialGroups.sort();
tutorialClasses.sort();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public class GroupType implements Comparable<GroupType> {

public static final String MESSAGE_CONSTRAINTS = "GroupType can only either be OP1 or OP2";
public static final String VALIDATION_REGEX = "[O|o][P|p][1/2]";

public final String value;
/**
Expand All @@ -24,7 +25,7 @@ public GroupType (String groupType) {
* Returns true if a given string is a valid name.
*/
public static boolean isValidGroupType(String test) {
return test.equals("OP1") || test.equals("OP2");
return test.matches(VALIDATION_REGEX);
}

private Integer parseGroupType(String groupType) {
Expand Down

0 comments on commit 6a2743e

Please sign in to comment.