Skip to content

Commit

Permalink
Merge pull request #110 from EthanWong6362/updates-before-demo
Browse files Browse the repository at this point in the history
Update things before the demo
  • Loading branch information
aakanshanarain committed Oct 27, 2021
2 parents cffa998 + 71c46fc commit 3bb0f64
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/main/java/seedu/modulink/logic/commands/AddFavCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static seedu.modulink.model.Model.PREDICATE_SHOW_ALL_PERSONS;

import java.util.function.Predicate;

import javafx.collections.ObservableList;
import seedu.modulink.commons.core.Messages;
import seedu.modulink.model.Model;
Expand All @@ -20,6 +22,9 @@ public class AddFavCommand extends Command {
+ "Parameters: Student_ID \n"
+ "Example: " + COMMAND_WORD + " A1234567X";

public static final String FAVOURITING_PROFILE_ERROR =
"You cannot add your own profile to your Favourites list.";

private final String studentId;

public AddFavCommand(String studentId) {
Expand All @@ -38,12 +43,17 @@ public CommandResult execute(Model model) {
if (person.getStudentId().toString().equalsIgnoreCase(studentId)) {
if (person.getIsFavourite()) {
return new CommandResult(String.format(Messages.MESSAGE_PERSON_ALREADY_FAVOURITE));
} else if (person.getIsMyProfile()) {
return new CommandResult(FAVOURITING_PROFILE_ERROR);
} else {
person.setFavouriteTrue();
noPersonFound = false;
}
}
}
// included this so the list will be properly updated
Predicate<Person> updatePredicate = unused -> false;
model.updateFilteredPersonList(updatePredicate);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);

if (noPersonFound) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import static seedu.modulink.model.Model.PREDICATE_SHOW_ALL_PERSONS;

import java.util.function.Predicate;

import javafx.collections.ObservableList;
import seedu.modulink.commons.core.Messages;
import seedu.modulink.model.Model;
import seedu.modulink.model.person.Person;


/**
* Removes person whose student ID matches the user input from favourites.
* ID matching is case insensitive.
Expand Down Expand Up @@ -42,6 +45,9 @@ public CommandResult execute(Model model) {
}
}
}
// included this so the list will be properly updated
Predicate<Person> updatePredicate = unused -> false;
model.updateFilteredPersonList(updatePredicate);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
if (noPersonFound) {
return new CommandResult(Messages.MESSAGE_NO_SUCH_ID_FOUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class GitHubUsername {
public static final String MESSAGE_CONSTRAINTS =
"GitHub username should start with an alphanumeric character, "
+ "can only contain alphanumeric characters and hyphens, and must not contain any spaces.";
public static final String VALIDATION_REGEX = "^[A-Za-z0-9]+[A-Za-z0-9_]+$";
public static final String VALIDATION_REGEX = "^[A-Za-z0-9]+[A-Za-z0-9_-]+$";
public final String value;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public ModuleContainsKeywordsPredicate(Set<Mod> mods) {
@Override
public boolean test(Person person) {
boolean doesMatchMod = false;
if (person.getIsMyProfile()) {
return false;
}
for (Mod mod : person.getMods()) {
for (Mod module : mods) {
if (module.modName.equalsIgnoreCase(mod.modName)) {
Expand Down
44 changes: 38 additions & 6 deletions src/main/java/seedu/modulink/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,60 @@ public static Person[] getSamplePersons() {
return new Person[] {
new Person(new Name("Alex Yeoh"), new StudentId("A1234567R"), new Phone("87438807"),
new Email("alexyeoh@example.com"), new GitHubUsername("alex_yeoh_y"),
new TelegramHandle("alexyeoh"), true,
getTagSet("CS2103T have group", "CS2106", "CS2101 need member"), false),
new TelegramHandle("alexyeoh"), false,
getTagSet("CS2103T", "CS2106", "CS2101 need member"), false),
new Person(new Name("Zachary Lau"), new StudentId("A1234567H"), new Phone("96523487"),
new Email("zachlau@example.com"), new GitHubUsername("zachattach"),
new TelegramHandle("zacharrryyyy"), false,
getTagSet("CS2100", "CS2106", "CS2101 need group"), false),
new Person(new Name("Ng Jia Yuan"), new StudentId("A1234567N"), new Phone("98432567"),
new Email("ngjy@example.com"), new GitHubUsername("yuan"),
new TelegramHandle("yuan"), false,
getTagSet("CS5210 need group", "CS2106", "CS2100 need member"), false),
new Person(new Name("Charlton Tan"), new StudentId("A1234567L"), new Phone("97324615"),
new Email("charles@example.com"), new GitHubUsername("C-dollarsign"),
new TelegramHandle("followmyspotify"), false,
getTagSet("CS2101 need group", "IS1101"), false),
new Person(new Name("Ahmad bin Ali"), new StudentId("A1234567B"), new Phone("95238541"),
new Email("aba@example.com"), new GitHubUsername("alibinahmad"),
new TelegramHandle("diversity"), false,
getTagSet("CS2100", "CS2106", "CS2103T need group"), false),
new Person(new Name("Bernice Yu"), new StudentId("A1234568X"), new Phone("99272758"),
new Email("berniceyu@example.com"), new GitHubUsername(null),
new TelegramHandle("berniceYuuu"), false,
getTagSet("CS2100", "CS3230 need group", "CS4234 need member"), false),
new Person(new Name("Charlotte Oliveiro"), new StudentId("A1234569Y"), new Phone("93210283"),
new Email("charlotte@example.com"), new GitHubUsername("charlotte_oliveiro"),
new TelegramHandle("charlotte24"), true,
new TelegramHandle("charlotte24"), false,
getTagSet("CS1101S", "CS3230 need member"), false),
new Person(new Name("David Li"), new StudentId("A1234570Z"), new Phone("91031282"),
new Email("lidavid@example.com"), new GitHubUsername("Davidli"),
new TelegramHandle(null), false,
getTagSet("IS1103"), false),
getTagSet("CS2101"), false),
new Person(new Name("Irfan Ibrahim"), new StudentId("A1234571R"), new Phone("92492021"),
new Email("irfan@example.com"), new GitHubUsername("Irfanib"),
new TelegramHandle("irfanibrahim"), false,
getTagSet("ST2334 need group", "GEA1000 need member"), false),
getTagSet("CS2101 need member", "ES2660 need group", "CS2103T"), false),
new Person(new Name("Roy Balakrishnan"), new StudentId("A1234572X"), new Phone("92624417"),
new Email("royb@example.com"), new GitHubUsername("Roybalakrishnan"),
new TelegramHandle("heyitsroy"), false,
getTagSet("LAJ1000 need member", "GES1021", "MA2001"), false)
getTagSet("CS2100", "CS2103T", "CS2101 need group"), false),
new Person(new Name("Nicole Wong"), new StudentId("A1234567Q"), new Phone("96523546"),
new Email("niolewong@example.com"), new GitHubUsername("NicoleW"),
new TelegramHandle("yellowNicole"), false,
getTagSet("CS2101 need member", "MA2001"), false),
new Person(new Name("Jeremy Tan"), new StudentId("A1234567W"), new Phone("96875439"),
new Email("jTan2000@example.com"), new GitHubUsername("jTanremy"),
new TelegramHandle("jeret"), false,
getTagSet("CS2101", "CS1101S need member", "CS2103T"), false),
new Person(new Name("Aniq Nathaniel"), new StudentId("A1234567E"), new Phone("92584685"),
new Email("aniqNathan@example.com"), new GitHubUsername("NathAniq"),
new TelegramHandle("Aniqle4urThoughts"), false,
getTagSet("CS2101 need group", "CS4234", "CS2103T need group"), false),
new Person(new Name("Timmy Turner"), new StudentId("A1234567E"), new Phone("95483265"),
new Email("timmyturns@example.com"), new GitHubUsername("TimTam"),
new TelegramHandle(null), false,
getTagSet("ST2334 need group", "GEA1000 need member"), false)
};
}

Expand Down

0 comments on commit 3bb0f64

Please sign in to comment.