Skip to content

Commit

Permalink
Merge branch 'master' into fix-alpha-bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
JYL27 authored Nov 7, 2024
2 parents f742051 + a47fade commit 3ce05b2
Show file tree
Hide file tree
Showing 53 changed files with 466 additions and 465 deletions.
4 changes: 2 additions & 2 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ How the parsing works:
The `Model` component,

* stores the contact data i.e., all `Person` objects (which are contained in a `UniquePersonList` object).
* a `Person` object stores `StudentId`, `Name`, `Address`, `Phone`, `Email`, `Tag`, `Course` objects.
* a `Person` object stores `StudentId`, `Name`, `Address`, `Phone`, `Email`, `Role`, `Course` objects.
* contains an ArrayList of `Module` objects which is optional.
* stores the currently 'selected' `Person` objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList<Person>` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
* stores a `UserPref` object that represents the user’s preferences. This is exposed to the outside as a `ReadOnlyUserPref` objects.
* is intentionally designed to be independent of other components (e.g., UI, Logic, Storage) to maintain a clean separation of concerns. This ensures that the Model layer is solely responsible for managing data and that data structures make sense on their own. This independence enables easier maintenance, testing, and adaptability of the data structures, as changes in one component (e.g., UI) do not affect the Model.

<box type="info" seamless>

**Note:** An alternative (arguably, a more OOP) model is given below. It has a `Role` list in the `AddressBook`, which `Person` references. This allows `AddressBook` to only require one `Role` object per unique tag, instead of each `Person` needing their own `Role` objects.<br>
**Note:** An alternative (arguably, a more OOP) model is given below. It has a `Role` list in the `AddressBook`, which `Person` references. This allows `AddressBook` to only require one `Role` object per unique role, instead of each `Person` needing their own `Role` objects.<br>

<puml src="diagrams/BetterModelClassDiagram.puml" width="450" />

Expand Down
6 changes: 3 additions & 3 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Adds a person contact to the EduContacts.

Format:
```bash
add ID n/NAME p/PHONE e/EMAIL a/ADDRESS c/COURSE t/TAG
add ID n/NAME p/PHONE e/EMAIL a/ADDRESS c/COURSE r/ROLE
```

Examples:
Expand Down Expand Up @@ -398,10 +398,10 @@ _Details coming soon ..._

Action | Format, Examples
-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------
**Add** | `add ID n/NAME p/PHONE e/EMAIL a/ADDRESS c/COURSE t/TAG` <br> e.g., `add 12345678 n/John Doe p/99999999 e/[email protected] a/123 Jane Doe Road c/Computer Science t/Student`
**Add** | `add ID n/NAME p/PHONE e/EMAIL a/ADDRESS c/COURSE r/ROLE` <br> e.g., `add 12345678 n/John Doe p/99999999 e/[email protected] a/123 Jane Doe Road c/Computer Science t/Student`
**Clear** | `clear`
**Delete** | `delete ID`<br> e.g., `delete 12345678`
**Edit** | `edit ID [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/COURSE] [t/TAG]…​`<br> e.g.,`edit 12345678 p/91234567 e/[email protected]`
**Edit** | `edit ID [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/COURSE] [r/ROLE]…​`<br> e.g.,`edit 12345678 p/91234567 e/[email protected]`
**Grade** | `grade ID m/MODULE g/GRADE` <br> e.g. `grade 12345678 m/CS2103T g/A`
**Add Module** | `module ID [m/MODULE]` <br> e.g., `add 12345678 m/CS2103T`
**Filter** | `filter [n/NAME] [c/COURSE] [m/MODULE]`<br> e.g., `filter n/James Jake`
Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/BetterModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Person *--> Email
Person *--> StudentId
Person *--> Address
Person *--> Course
Person *--> Tag
Person *--> Role
Person *--> "*"Module

Module *--> "0..1" Grade
Expand Down
4 changes: 2 additions & 2 deletions docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Class Course
Class Email
Class Name
Class Phone
Class Tag
Class Role
Class Module
Class Grade

Expand All @@ -46,7 +46,7 @@ Person *--> Name
Person *--> Phone
Person *--> Email
Person *--> Address
Person *--> "*" Tag
Person *--> "*" Role
Person *--> Course
Person *--> Module

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public static String format(Person person) {
.append(person.getAddress())
.append("; Course: ")
.append(person.getCourse())
.append("; Tag: ")
.append(person.getTag());
.append("; Role: ")
.append(person.getRole());
return builder.toString();
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
Expand All @@ -29,15 +29,15 @@ public class AddCommand extends Command {
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_ADDRESS + "ADDRESS "
+ PREFIX_COURSE + "COURSE "
+ PREFIX_TAG + "TAG\n"
+ PREFIX_ROLE + "ROLE\n"
+ "Example: " + COMMAND_WORD + " "
+ "12345678 "
+ PREFIX_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_COURSE + "Computer Science "
+ PREFIX_TAG + "Student ";
+ PREFIX_ROLE + "Student ";


public static final String MESSAGE_SUCCESS = "New person added: %1$s";
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_MODULE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;

import java.util.ArrayList;
Expand All @@ -27,8 +27,8 @@
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Role;
import seedu.address.model.person.StudentId;
import seedu.address.model.person.Tag;

/**
* Edits the details of an existing person in EduContacts.
Expand All @@ -48,7 +48,7 @@ public class EditCommand extends Command {
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_ADDRESS + "ADDRESS] "
+ "[" + PREFIX_COURSE + " COURSE] "
+ "[" + PREFIX_TAG + "TAG] ...\n"
+ "[" + PREFIX_ROLE + "ROLE] ...\n"
+ "Example: " + COMMAND_WORD + " 12345678 "
+ PREFIX_PHONE + "91234567 "
+ PREFIX_EMAIL + "[email protected]"
Expand Down Expand Up @@ -116,7 +116,7 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript
Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail());
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress());
Course updatedCourse = editPersonDescriptor.getCourse().orElse(personToEdit.getCourse());
Tag updatedTag = editPersonDescriptor.getTag().orElse(personToEdit.getTag());
Role updatedRole = editPersonDescriptor.getRole().orElse(personToEdit.getRole());

ArrayList<Module> updatedModules = editPersonDescriptor.getModules().orElse(personToEdit.getModules());
if (editPersonDescriptor.hasModuleChanges()) {
Expand Down Expand Up @@ -146,7 +146,7 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript
}

Person editedPerson = new Person(personToEdit.getStudentId(), updatedName, updatedPhone, updatedEmail,
updatedAddress, updatedCourse, updatedTag, updatedModules);
updatedAddress, updatedCourse, updatedRole, updatedModules);

return editedPerson;
}
Expand Down Expand Up @@ -186,7 +186,7 @@ public static class EditPersonDescriptor {
private Email email;
private Address address;
private Course course;
private Tag tag;
private Role role;
private ArrayList<Module> modules;
private Module oldModule;
private Module newModule;
Expand All @@ -195,7 +195,7 @@ public EditPersonDescriptor() {}

/**
* Copy constructor.
* A defensive copy of {@code tags} is used internally.
* A defensive copy of {@code roles} is used internally.
*/
public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setStudentId(null);
Expand All @@ -204,7 +204,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setEmail(toCopy.email);
setAddress(toCopy.address);
setCourse(toCopy.course);
setTag(toCopy.tag);
setRole(toCopy.role);
setModules(toCopy.modules);
setOldModule(toCopy.oldModule);
setNewModule(toCopy.newModule);
Expand All @@ -214,7 +214,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(studentId, name, phone, email, address, course, tag, modules)
return CollectionUtil.isAnyNonNull(studentId, name, phone, email, address, course, role, modules)
|| hasModuleChanges();
}

Expand Down Expand Up @@ -283,20 +283,20 @@ public Optional<Module> getOldModule() {
}

/**
* Sets {@code tags} to this object's {@code tags}.
* A defensive copy of {@code tags} is used internally.
* Sets {@code roles} to this object's {@code roles}.
* A defensive copy of {@code roles} is used internally.
*/
public void setTag(Tag tag) {
this.tag = tag;
public void setRole(Role role) {
this.role = role;
}

/**
* Returns an unmodifiable tag set, which throws {@code UnsupportedOperationException}
* Returns an unmodifiable role set, which throws {@code UnsupportedOperationException}
* if modification is attempted.
* Returns {@code Optional#empty()} if {@code tags} is null.
* Returns {@code Optional#empty()} if {@code roles} is null.
*/
public Optional<Tag> getTag() {
return Optional.ofNullable(tag);
public Optional<Role> getRole() {
return Optional.ofNullable(role);
}

public void setModules(ArrayList<Module> modules) {
Expand Down Expand Up @@ -327,7 +327,7 @@ public boolean equals(Object other) {
&& Objects.equals(email, otherEditPersonDescriptor.email)
&& Objects.equals(address, otherEditPersonDescriptor.address)
&& Objects.equals(course, otherEditPersonDescriptor.course)
&& Objects.equals(tag, otherEditPersonDescriptor.tag)
&& Objects.equals(role, otherEditPersonDescriptor.role)
&& Objects.equals(modules, otherEditPersonDescriptor.modules)
&& Objects.equals(oldModule, otherEditPersonDescriptor.oldModule)
&& Objects.equals(newModule, otherEditPersonDescriptor.newModule);
Expand All @@ -351,7 +351,7 @@ public String toString() {
.add("email", email)
.add("address", address)
.add("course", course)
.add("tags", tag)
.add("roles", role)
.add("modules", modules)
.add("oldModule", oldModule)
.add("newModule", newModule)
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/seedu/address/logic/parser/AddCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE;

import java.util.stream.Stream;

Expand All @@ -18,8 +18,8 @@
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Role;
import seedu.address.model.person.StudentId;
import seedu.address.model.person.Tag;

/**
* Parses input arguments and creates a new AddCommand object
Expand All @@ -34,7 +34,7 @@ public class AddCommandParser implements Parser<AddCommand> {
public AddCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL,
PREFIX_ADDRESS, PREFIX_COURSE, PREFIX_TAG);
PREFIX_ADDRESS, PREFIX_COURSE, PREFIX_ROLE);
String preamble = argMultimap.getPreamble();

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL,
Expand All @@ -52,14 +52,14 @@ public AddCommand parse(String args) throws ParseException {
Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get());
Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get());
Course course = ParserUtil.parseCourse(argMultimap.getValue(PREFIX_COURSE).get());
Tag tag;
if (argMultimap.getValue(PREFIX_TAG).isPresent()) {
tag = ParserUtil.parseTag(argMultimap.getValue(PREFIX_TAG).get());
Role role;
if (argMultimap.getValue(PREFIX_ROLE).isPresent()) {
role = ParserUtil.parseRole(argMultimap.getValue(PREFIX_ROLE).get());
} else {
tag = new Tag("Student");
role = new Role("Student");
}

Person person = new Person(studentId, name, phone, email, address, course, tag);
Person person = new Person(studentId, name, phone, email, address, course, role);

return new AddCommand(person);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void verifyNoDuplicateStudentId(String input) throws ParseException {
if (!token.startsWith("m/") && !token.startsWith("g/")
&& !token.startsWith("n/") && !token.startsWith("p/")
&& !token.startsWith("e/") && !token.startsWith("a/")
&& !token.startsWith("c/") && !token.startsWith("t/")) {
&& !token.startsWith("c/") && !token.startsWith("r/")) {

boolean isStudentId = token.matches("^[!?&@]*\\d{7,8}$")
|| token.matches("^[A-Za-z]\\d{7}[A-Za-z]?$");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CliSyntax {
public static final Prefix PREFIX_EMAIL = new Prefix("e/");
public static final Prefix PREFIX_ADDRESS = new Prefix("a/");
public static final Prefix PREFIX_COURSE = new Prefix("c/");
public static final Prefix PREFIX_TAG = new Prefix("t/");
public static final Prefix PREFIX_ROLE = new Prefix("r/");
public static final Prefix PREFIX_MODULE = new Prefix("m/");
public static final Prefix PREFIX_GRADE = new Prefix("g/");
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_MODULE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE;

import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.EditCommand.EditPersonDescriptor;
Expand All @@ -30,7 +30,7 @@ public EditCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
PREFIX_COURSE, PREFIX_TAG, PREFIX_MODULE);
PREFIX_COURSE, PREFIX_ROLE, PREFIX_MODULE);
StudentId studentId;
try {
studentId = ParserUtil.parseStudentId(argMultimap.getPreamble());
Expand Down Expand Up @@ -69,8 +69,8 @@ public EditCommand parse(String args) throws ParseException {
editPersonDescriptor.setCourse(ParserUtil.parseCourse(argMultimap.getValue(PREFIX_COURSE).get()
));
}
if (argMultimap.getValue(PREFIX_TAG).isPresent()) {
editPersonDescriptor.setTag(ParserUtil.parseTag(argMultimap.getValue(PREFIX_TAG).get()));
if (argMultimap.getValue(PREFIX_ROLE).isPresent()) {
editPersonDescriptor.setRole(ParserUtil.parseRole(argMultimap.getValue(PREFIX_ROLE).get()));
}
}

Expand Down
34 changes: 17 additions & 17 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import seedu.address.model.person.Module;
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Role;
import seedu.address.model.person.StudentId;
import seedu.address.model.person.Tag;

/**
* Contains utility methods used for parsing strings in the various *Parser classes.
Expand Down Expand Up @@ -118,31 +118,31 @@ public static Email parseEmail(String email) throws ParseException {
}

/**
* Parses a {@code String tag} into a {@code Tag}.
* Parses a {@code String role} into a {@code Role}.
* Leading and trailing whitespaces will be trimmed.
*
* @throws ParseException if the given {@code tag} is invalid.
* @throws ParseException if the given {@code role} is invalid.
*/
public static Tag parseTag(String tag) throws ParseException {
requireNonNull(tag);
String trimmedTag = tag.trim();
if (!Tag.isValidTag(trimmedTag)) {
throw new ParseException(Tag.MESSAGE_CONSTRAINTS);
public static Role parseRole(String role) throws ParseException {
requireNonNull(role);
String trimmedRole = role.trim();
if (!Role.isValidRole(trimmedRole)) {
throw new ParseException(Role.MESSAGE_CONSTRAINTS);
}
trimmedTag = makeCapitalise(trimmedTag);
return new Tag(trimmedTag);
trimmedRole = makeCapitalise(trimmedRole);
return new Role(trimmedRole);
}

/**
* Parses {@code Collection<String> tags} into a {@code Set<Tag>}.
* Parses {@code Collection<String> roles} into a {@code Set<Role>}.
*/
public static Set<Tag> parseTags(Collection<String> tags) throws ParseException {
requireNonNull(tags);
final Set<Tag> tagSet = new HashSet<>();
for (String tagName : tags) {
tagSet.add(parseTag(tagName));
public static Set<Role> parseRoles(Collection<String> roles) throws ParseException {
requireNonNull(roles);
final Set<Role> roleSet = new HashSet<>();
for (String roleName : roles) {
roleSet.add(parseRole(roleName));
}
return tagSet;
return roleSet;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/Prefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* A prefix that marks the beginning of an argument in an arguments string.
* E.g. 't/' in 'add James t/ friend'.
* E.g. 'r/' in 'add James r/Student'.
*/
public class Prefix {
private final String prefix;
Expand Down
Loading

0 comments on commit 3ce05b2

Please sign in to comment.