diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 5d5b81738f9..1dd29446257 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -1,9 +1,10 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; +import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_COURSE; 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_REMARK; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_STUDENTS; @@ -41,6 +42,7 @@ public class EditCommand extends Command { + "[" + PREFIX_NAME + "NAME] " + "[" + PREFIX_COURSE + "COURSE] " + "[" + PREFIX_EMAIL + "EMAIL] " + + "[" + PREFIX_REMARK + "REMARK] " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " 1 " + PREFIX_COURSE + "CS2103T " @@ -96,7 +98,7 @@ private static Student createEditedStudent(Student studentToEdit, EditStudentDes Name updatedName = editStudentDescriptor.getName().orElse(studentToEdit.getName()); Course updatedCourse = editStudentDescriptor.getCourse().orElse(studentToEdit.getCourse()); Email updatedEmail = editStudentDescriptor.getEmail().orElse(studentToEdit.getEmail()); - Remark updatedRemark = studentToEdit.getRemark(); // edit command does not allow editing remarks + Remark updatedRemark = editStudentDescriptor.getRemark().orElse(studentToEdit.getRemark()); Set updatedTags = editStudentDescriptor.getTags().orElse(studentToEdit.getTags()); return new Student(updatedName, updatedCourse, updatedEmail, updatedRemark, updatedTags); @@ -134,6 +136,7 @@ public static class EditStudentDescriptor { private Name name; private Course course; private Email email; + private Remark remark; private Set tags; public EditStudentDescriptor() {} @@ -146,6 +149,7 @@ public EditStudentDescriptor(EditStudentDescriptor toCopy) { setName(toCopy.name); setCourse(toCopy.course); setEmail(toCopy.email); + setRemark(toCopy.remark); setTags(toCopy.tags); } @@ -153,7 +157,7 @@ public EditStudentDescriptor(EditStudentDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(name, course, email, tags); + return CollectionUtil.isAnyNonNull(name, course, email, remark, tags); } public void setName(Name name) { @@ -180,6 +184,14 @@ public Optional getEmail() { return Optional.ofNullable(email); } + public void setRemark(Remark remark) { + this.remark = remark; + } + + public Optional getRemark() { + return Optional.ofNullable(remark); + } + /** * Sets {@code tags} to this object's {@code tags}. * A defensive copy of {@code tags} is used internally. @@ -212,6 +224,7 @@ public boolean equals(Object other) { return Objects.equals(name, otherEditStudentDescriptor.name) && Objects.equals(course, otherEditStudentDescriptor.course) && Objects.equals(email, otherEditStudentDescriptor.email) + && Objects.equals(remark, otherEditStudentDescriptor.remark) && Objects.equals(tags, otherEditStudentDescriptor.tags); } @@ -221,6 +234,7 @@ public String toString() { .add("name", name) .add("course", course) .add("email", email) + .add("email", remark) .add("tags", tags) .toString(); } diff --git a/src/main/java/seedu/address/logic/commands/ExitCommand.java b/src/main/java/seedu/address/logic/commands/ExitCommand.java index 3dd85a8ba90..2e2bdb5ed0c 100644 --- a/src/main/java/seedu/address/logic/commands/ExitCommand.java +++ b/src/main/java/seedu/address/logic/commands/ExitCommand.java @@ -9,7 +9,7 @@ public class ExitCommand extends Command { public static final String COMMAND_WORD = "exit"; - public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ..."; + public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting CodeSphere ..."; @Override public CommandResult execute(Model model) { diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index 58b0b9e5eff..61e48e404af 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -5,6 +5,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_COURSE; 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_REMARK; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import java.util.Collection; @@ -30,7 +31,7 @@ public class EditCommandParser implements Parser { public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_COURSE, PREFIX_EMAIL, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_COURSE, PREFIX_EMAIL, PREFIX_REMARK, PREFIX_TAG); Index index; @@ -40,7 +41,7 @@ public EditCommand parse(String args) throws ParseException { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_COURSE, PREFIX_EMAIL); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_COURSE, PREFIX_REMARK, PREFIX_EMAIL); EditCommand.EditStudentDescriptor editStudentDescriptor = new EditCommand.EditStudentDescriptor(); @@ -53,6 +54,9 @@ public EditCommand parse(String args) throws ParseException { if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) { editStudentDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get())); } + if (argMultimap.getValue(PREFIX_REMARK).isPresent()) { + editStudentDescriptor.setRemark(ParserUtil.parseRemark(argMultimap.getValue(PREFIX_REMARK).get())); + } parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editStudentDescriptor::setTags); diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index a78d11b0ae6..f227322fd21 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -12,6 +12,7 @@ import seedu.address.model.person.Course; import seedu.address.model.person.Email; import seedu.address.model.person.Name; +import seedu.address.model.person.Remark; import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; @@ -80,6 +81,16 @@ public static Email parseEmail(String email) throws ParseException { return new Email(trimmedEmail); } + /** + * Parses a {@code String remark} into an {@code Remark}. + * Leading and trailing whitespaces will be trimmed. + */ + public static Remark parseRemark(String remark) { + requireNonNull(remark); + String trimmedRemark = remark.trim(); + return new Remark(trimmedRemark); + } + /** * Parses a {@code StudentRank tag} into a {@code Tag}. * Leading and trailing whitespaces will be trimmed. diff --git a/src/main/java/seedu/address/model/person/Student.java b/src/main/java/seedu/address/model/person/Student.java index 232ce36d6a7..73802cfb379 100644 --- a/src/main/java/seedu/address/model/person/Student.java +++ b/src/main/java/seedu/address/model/person/Student.java @@ -29,7 +29,7 @@ public class Student { * Every field must be present and not null. */ public Student(Name name, Course course, Email email, Remark remark, Set tags) { - requireAllNonNull(name, course, email, tags); + requireAllNonNull(name, course, email, remark, tags); this.name = name; this.course = course; this.email = email; @@ -95,13 +95,14 @@ public boolean equals(Object other) { return otherStudent.getName().equals(getName()) && otherStudent.getCourse().equals(getCourse()) && otherStudent.getEmail().equals(getEmail()) + && otherStudent.getRemark().equals(getRemark()) && otherStudent.getTags().equals(getTags()); } @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, course, email, tags); + return Objects.hash(name, course, email, remark, tags); } @Override