From d9de626d1ed17e5c418f7efd30cdee9dd8a9f846 Mon Sep 17 00:00:00 2001 From: abwilli Date: Sat, 13 Apr 2019 15:42:14 +0800 Subject: [PATCH 1/6] endorse clear test --- .../logic/commands/EndorseCommandTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java b/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java index aa7de72edad9..90a7c1a601f3 100644 --- a/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java @@ -11,6 +11,7 @@ import seedu.address.logic.CommandHistory; +import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.AddressBook; import seedu.address.model.Model; import seedu.address.model.ModelManager; @@ -50,4 +51,31 @@ public void execute_endorsePerson_success() { assertCommandSuccess(endorseCommand, model, commandHistory, expectedMessage, expectedModel); } + + @Test + public void execute_clearEndorsePerson_success() throws CommandException { + Person samplePerson = model.getFilteredPersonList().get(0); + SkillsTag sampleEndorseTag = new SkillsTag(VALID_ENDORSE_NAME, "endorse"); + Set samplePersonTags = new HashSet<>(samplePerson.getTags()); + Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + EndorseCommand endorseCommand = new EndorseCommand(ENDORSE_PROCESS, INDEX_FIRST_PERSON, VALID_ENDORSE_NAME); + endorseCommand.execute(model, new CommandHistory()); + + endorseCommand.execute(expectedModel, new CommandHistory()); + EndorseCommand clearEndorseCommand = new EndorseCommand(CLEAR_PROCESS, INDEX_FIRST_PERSON, VALID_ENDORSE_NAME); + + samplePersonTags.remove(sampleEndorseTag); + Person editedPerson = new Person(samplePerson.getName(), + samplePerson.getPhone(), samplePerson.getEmail(), + samplePerson.getEducation(), samplePerson.getGpa(), + samplePerson.getAddress(), samplePersonTags); + String expectedMessage = String.format(EndorseCommand.MESSAGE_REMOVE_ENDORSE_SUCESS, editedPerson.getName()); + + + expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); + expectedModel.commitAddressBook(); + + assertCommandSuccess(clearEndorseCommand, model, commandHistory, expectedMessage, expectedModel); + } + } From 09206ba31bb91f111f5f1092b70af09bbe187fcc Mon Sep 17 00:00:00 2001 From: abwilli Date: Sat, 13 Apr 2019 15:48:07 +0800 Subject: [PATCH 2/6] check style --- .../java/seedu/address/logic/commands/EndorseCommandTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java b/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java index 90a7c1a601f3..7f819cdf0b32 100644 --- a/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java @@ -51,7 +51,6 @@ public void execute_endorsePerson_success() { assertCommandSuccess(endorseCommand, model, commandHistory, expectedMessage, expectedModel); } - @Test public void execute_clearEndorsePerson_success() throws CommandException { Person samplePerson = model.getFilteredPersonList().get(0); From 8fdf6c7821a30076f35f3d71b69dba011d4e5ca1 Mon Sep 17 00:00:00 2001 From: abwilli Date: Sat, 13 Apr 2019 16:08:49 +0800 Subject: [PATCH 3/6] endorse duplicate test --- .../address/logic/commands/EndorseCommandTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java b/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java index 7f819cdf0b32..68887f868b4f 100644 --- a/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java @@ -1,5 +1,6 @@ package seedu.address.logic.commands; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; @@ -53,6 +54,7 @@ public void execute_endorsePerson_success() { } @Test public void execute_clearEndorsePerson_success() throws CommandException { + Person samplePerson = model.getFilteredPersonList().get(0); SkillsTag sampleEndorseTag = new SkillsTag(VALID_ENDORSE_NAME, "endorse"); Set samplePersonTags = new HashSet<>(samplePerson.getTags()); @@ -75,6 +77,18 @@ public void execute_clearEndorsePerson_success() throws CommandException { expectedModel.commitAddressBook(); assertCommandSuccess(clearEndorseCommand, model, commandHistory, expectedMessage, expectedModel); + + } + + @Test + public void execute_endorseDuplicate_failure() throws CommandException { + + EndorseCommand endorseCommand = new EndorseCommand(ENDORSE_PROCESS, INDEX_FIRST_PERSON, VALID_ENDORSE_NAME); + endorseCommand.execute(model, new CommandHistory()); + String expectedMessage = String.format(EndorseCommand.MESSAGE_DUPLICATE_PERSON); + + assertCommandFailure(endorseCommand, model, commandHistory, expectedMessage); + } } From cea5bb00d9ac1c8f5a58f98a69c296b268c067ba Mon Sep 17 00:00:00 2001 From: abwilli Date: Sat, 13 Apr 2019 16:42:39 +0800 Subject: [PATCH 4/6] more endorse command tests --- .../logic/commands/EndorseCommandTest.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java b/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java index 68887f868b4f..84ad3b371751 100644 --- a/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EndorseCommandTest.java @@ -10,6 +10,8 @@ import org.junit.Test; +import seedu.address.commons.core.Messages; +import seedu.address.commons.core.index.Index; import seedu.address.logic.CommandHistory; import seedu.address.logic.commands.exceptions.CommandException; @@ -26,7 +28,6 @@ public class EndorseCommandTest { private static final int CLEAR_PROCESS = 1; private static final int ENDORSE_PROCESS = 0; - private static final String INVALID_ENDORSE_NAME = null; private static final String VALID_ENDORSE_NAME = "John Smith"; private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); private CommandHistory commandHistory = new CommandHistory(); @@ -91,4 +92,21 @@ public void execute_endorseDuplicate_failure() throws CommandException { } + @Test + public void execute_clearEmptyEndorsement_failure() { + EndorseCommand clearCommand = new EndorseCommand(CLEAR_PROCESS, INDEX_FIRST_PERSON, VALID_ENDORSE_NAME); + String expectedMessage = String.format(EndorseCommand.MESSAGE_MISSING_ENDORSEMENT); + + assertCommandFailure(clearCommand, model, commandHistory, expectedMessage); + } + + @Test + public void execute_endorseIndexOutBounds_failure() { + Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); + EndorseCommand endorseCommand = new EndorseCommand(ENDORSE_PROCESS, outOfBoundIndex, VALID_ENDORSE_NAME); + String expectedMessage = Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; + + assertCommandFailure(endorseCommand, model, commandHistory, expectedMessage); + } + } From 72d7aecee0ae10d2ce53f65a672ad9e7282ba9ea Mon Sep 17 00:00:00 2001 From: abwilli Date: Sat, 13 Apr 2019 17:26:14 +0800 Subject: [PATCH 5/6] edit command test --- .../logic/commands/EditCommandTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 74fed93316fb..b64c09b9ecf0 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -14,12 +14,16 @@ import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import java.util.HashSet; +import java.util.Set; + import org.junit.Test; import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; import seedu.address.logic.CommandHistory; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.AddressBook; import seedu.address.model.Model; import seedu.address.model.ModelManager; @@ -115,6 +119,28 @@ public void execute_filteredList_success() { assertCommandSuccess(editCommand, model, commandHistory, expectedMessage, expectedModel); } + @Test + public void execute_editTagsWithEndorsements_success() throws CommandException { + + Person samplePerson = model.getFilteredPersonList().get(0); + SkillsTag sampleEndorseTag = new SkillsTag(VALID_NAME_BOB, "endorse"); + Set samplePersonTags = new HashSet<>(samplePerson.getTags()); + Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); + EndorseCommand endorseCommand = new EndorseCommand(0, INDEX_FIRST_PERSON, VALID_NAME_BOB); + endorseCommand.execute(model, new CommandHistory()); + Person endorsedPerson = model.getFilteredPersonList().get(0); + + endorseCommand.execute(expectedModel, new CommandHistory()); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, endorsedPerson); + + + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(samplePerson).build(); + EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, descriptor); + editCommand.execute(expectedModel, new CommandHistory()); + + assertCommandSuccess(editCommand, model, commandHistory, expectedMessage, expectedModel); + } + @Test public void execute_duplicatePersonUnfilteredList_failure() { Person firstPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); From 47d7c6ed1041c6b5c620da638a91ac9ffb770a5b Mon Sep 17 00:00:00 2001 From: charnixon Date: Sat, 13 Apr 2019 17:39:56 +0800 Subject: [PATCH 6/6] addition of the Degree and usability in ui --- .../address/logic/commands/AddCommand.java | 3 + .../address/logic/commands/EditCommand.java | 21 +++- .../logic/commands/EndorseCommand.java | 2 +- .../commands/sortmethods/SortSkills.java | 11 +- .../logic/parser/AddCommandParser.java | 19 ++-- .../seedu/address/logic/parser/CliSyntax.java | 5 + .../logic/parser/EditCommandParser.java | 7 +- .../address/logic/parser/ParserUtil.java | 22 +++- .../seedu/address/model/person/Degree.java | 81 ++++++++++++++ .../seedu/address/model/person/Person.java | 10 +- .../address/model/util/SampleDataUtil.java | 105 +++++++++--------- .../address/storage/JsonAdaptedPerson.java | 22 +++- .../java/seedu/address/ui/PersonCard.java | 9 ++ src/main/resources/view/PersonListCard.fxml | 3 + .../duplicatePersonAddressBook.json | 2 + .../invalidPersonAddressBook.json | 1 + .../typicalPersonsAddressBook.json | 7 ++ .../seedu/address/logic/LogicManagerTest.java | 3 +- .../logic/commands/CommandTestUtil.java | 8 ++ .../logic/commands/EndorseCommandTest.java | 2 +- .../logic/parser/AddCommandParserTest.java | 53 +++------ .../address/logic/parser/ParserUtilTest.java | 78 +++++++++++++ .../storage/JsonAdaptedPersonTest.java | 23 ++-- .../testutil/EditPersonDescriptorBuilder.java | 28 +++++ .../seedu/address/testutil/PersonBuilder.java | 14 ++- .../seedu/address/testutil/PersonUtil.java | 12 +- .../address/testutil/TypicalPersons.java | 31 +++--- .../seedu/address/ui/PersonListPanelTest.java | 12 +- 28 files changed, 427 insertions(+), 167 deletions(-) create mode 100644 src/main/java/seedu/address/model/person/Degree.java diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 4afdcfb750b0..aa2c6f349184 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -5,6 +5,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_EDUCATION; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_GPA; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DEGREE; 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_POS; @@ -29,6 +30,7 @@ public class AddCommand extends Command { + PREFIX_EMAIL + "EMAIL " + PREFIX_EDUCATION + "EDUCATION " + PREFIX_GPA + "Gpa " + + PREFIX_DEGREE + "DEGREE " + PREFIX_ADDRESS + "ADDRESS " + "[" + PREFIX_SKILL + "TAG]...\n" + "Example: " + COMMAND_WORD + " " @@ -37,6 +39,7 @@ public class AddCommand extends Command { + PREFIX_EMAIL + "johnd@example.com " + PREFIX_EDUCATION + "NUS " + PREFIX_GPA + "3 " + + PREFIX_DEGREE + "Bachelors " + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " + PREFIX_SKILL + "Java " + PREFIX_POS + "Software Engineer"; diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 9e881c4d9a4e..36d1936eea9e 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -5,6 +5,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_EDUCATION; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_GPA; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DEGREE; 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_SKILL; @@ -25,6 +26,7 @@ import seedu.address.model.person.Education; import seedu.address.model.person.Email; import seedu.address.model.person.Gpa; +import seedu.address.model.person.Degree; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -46,6 +48,7 @@ public class EditCommand extends Command { + "[" + PREFIX_EMAIL + "EMAIL] " + "[" + PREFIX_EDUCATION + "EDUCATION] " + "[" + PREFIX_GPA + "Gpa] " + + "[" + PREFIX_DEGREE + "DEGREE] " + "[" + PREFIX_ADDRESS + "ADDRESS] " + "[" + PREFIX_SKILL + "TAG]...\n" + "Example: " + COMMAND_WORD + " 1 " @@ -94,7 +97,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command Set editedTags = new HashSet<>(changedPerson.getTags()); editedTags.addAll(endorsements); Person editedPerson = new Person(changedPerson.getName(), changedPerson.getPhone(), changedPerson.getEmail(), - changedPerson.getEducation(), changedPerson.getGpa(), changedPerson.getAddress(), editedTags); + changedPerson.getEducation(), changedPerson.getGpa(), changedPerson.getDegree(), changedPerson.getAddress(), editedTags); if (!personToEdit.isSamePerson(editedPerson) && model.hasPerson(editedPerson)) { @@ -118,11 +121,12 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); Education updatedEducation = editPersonDescriptor.getEducation().orElse(personToEdit.getEducation()); Gpa updatedGpa = editPersonDescriptor.getGpa().orElse(personToEdit.getGpa()); + Degree updatedDegree = editPersonDescriptor.getDegree().orElse(personToEdit.getDegree()); Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); return new Person(updatedName, updatedPhone, updatedEmail, updatedEducation, - updatedGpa, updatedAddress, updatedTags); + updatedGpa, updatedDegree, updatedAddress, updatedTags); } @Override @@ -153,6 +157,7 @@ public static class EditPersonDescriptor { private Email email; private Education education; private Gpa gpa; + private Degree degree; private Address address; private Set tags; @@ -168,6 +173,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setEmail(toCopy.email); setEducation(toCopy.education); setGpa(toCopy.gpa); + setDegree(toCopy.degree); setAddress(toCopy.address); setTags(toCopy.tags); } @@ -176,7 +182,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(name, phone, email, education, gpa, address, tags); + return CollectionUtil.isAnyNonNull(name, phone, email, education, gpa, degree, address, tags); } public void setName(Name name) { @@ -219,6 +225,14 @@ public Optional getGpa() { return Optional.ofNullable(gpa); } + public void setDegree(Degree degree) { + this.degree = degree; + } + + public Optional getDegree() { + return Optional.ofNullable(degree); + } + public void setAddress(Address address) { this.address = address; } @@ -264,6 +278,7 @@ && getPhone().equals(e.getPhone()) && getEmail().equals(e.getEmail()) && getEducation().equals(e.getEducation()) && getGpa().equals(e.getGpa()) + && getDegree().equals(e.getDegree()) && getAddress().equals(e.getAddress()) && getTags().equals(e.getTags()); } diff --git a/src/main/java/seedu/address/logic/commands/EndorseCommand.java b/src/main/java/seedu/address/logic/commands/EndorseCommand.java index 0f06ef955fb2..635f03c0193c 100644 --- a/src/main/java/seedu/address/logic/commands/EndorseCommand.java +++ b/src/main/java/seedu/address/logic/commands/EndorseCommand.java @@ -86,7 +86,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command } Person editedPerson = new Person(personToEdit.getName(), personToEdit.getPhone(), personToEdit.getEmail(), - personToEdit.getEducation(), personToEdit.getGpa(), personToEdit.getAddress(), personTags); + personToEdit.getEducation(), personToEdit.getGpa(), personToEdit.getDegree(), personToEdit.getAddress(), personTags); model.setPerson(personToEdit, editedPerson); diff --git a/src/main/java/seedu/address/logic/commands/sortmethods/SortSkills.java b/src/main/java/seedu/address/logic/commands/sortmethods/SortSkills.java index 0752af59e823..62f98993d832 100644 --- a/src/main/java/seedu/address/logic/commands/sortmethods/SortSkills.java +++ b/src/main/java/seedu/address/logic/commands/sortmethods/SortSkills.java @@ -5,13 +5,7 @@ import java.util.LinkedHashSet; import java.util.List; -import seedu.address.model.person.Address; -import seedu.address.model.person.Education; -import seedu.address.model.person.Email; -import seedu.address.model.person.Gpa; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.person.*; import seedu.address.model.tag.SkillsTag; /** @@ -61,11 +55,12 @@ private List orderPersonsTags(List lastShownList, String prefix) Email email = person.getEmail(); Education education = person.getEducation(); Gpa gpa = person.getGpa(); + Degree degree = person.getDegree(); Address address = person.getAddress(); //change list back to set LinkedHashSet tagSet = SortUtil.toTags(individualSortedTags); - Person newPerson = new Person(name, phone, email, education, gpa, address, tagSet); + Person newPerson = new Person(name, phone, email, education, gpa, degree, address, tagSet); personsWithCorrectTagOrder.add(newPerson); } return personsWithCorrectTagOrder; diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index d24b9a7aa45b..b107213c478a 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -6,6 +6,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_EDUCATION; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_GPA; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DEGREE; 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_POS; @@ -21,6 +22,7 @@ import seedu.address.model.person.Education; import seedu.address.model.person.Email; import seedu.address.model.person.Gpa; +import seedu.address.model.person.Degree; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -39,11 +41,12 @@ public class AddCommandParser implements Parser { */ public AddCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, - PREFIX_SKILL, PREFIX_POS, PREFIX_GPA, PREFIX_EDUCATION); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + PREFIX_EDUCATION, PREFIX_GPA, PREFIX_DEGREE, PREFIX_ADDRESS, + PREFIX_SKILL, PREFIX_POS); - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, - PREFIX_GPA, PREFIX_EDUCATION) + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + PREFIX_EDUCATION, PREFIX_GPA, PREFIX_DEGREE, PREFIX_ADDRESS) || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } @@ -52,6 +55,9 @@ public AddCommand parse(String args) throws ParseException { Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()); + Gpa gpa = ParserUtil.parseGpa(argMultimap.getValue(PREFIX_GPA).get()); + Education education = ParserUtil.parseEducation(argMultimap.getValue(PREFIX_EDUCATION).get()); + Degree degree = ParserUtil.parseDegree(argMultimap.getValue(PREFIX_DEGREE).get()); Set skillList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_SKILL), "skill"); Set posList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_POS), "pos"); @@ -59,10 +65,9 @@ public AddCommand parse(String args) throws ParseException { Set tagList = new HashSet<>(); tagList.addAll(skillList); tagList.addAll(posList); - Gpa gpa = ParserUtil.parseGpa(argMultimap.getValue(PREFIX_GPA).get()); - Education education = ParserUtil.parseEducation(argMultimap.getValue(PREFIX_EDUCATION).get()); - Person person = new Person(name, phone, email, education, gpa, address, tagList); + + Person person = new Person(name, phone, email, education, gpa, degree, address, tagList); return new AddCommand(person); } diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 6c48f05bf218..6bc2a8cfa0ee 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -14,6 +14,7 @@ public class CliSyntax { public static final Prefix PREFIX_POS = new Prefix("position/"); public static final Prefix PREFIX_GPA = new Prefix("g/"); public static final Prefix PREFIX_EDUCATION = new Prefix("d/"); + public static final Prefix PREFIX_DEGREE = new Prefix("deg/"); /* Prefix for Filtering definitions */ public static final Prefix PREFIX_FILTER_NAME = new Prefix("name<"); @@ -33,6 +34,8 @@ public class CliSyntax { public static final Prefix PREFIX_FILTER_ENDORSEMENT_REVERSE = new Prefix(">end"); public static final Prefix PREFIX_FILTER_GPA = new Prefix("gpa<"); public static final Prefix PREFIX_FILTER_GPA_REVERSE = new Prefix(">gpa"); + public static final Prefix PREFIX_FILTER_DEGREE = new Prefix("deg<"); + public static final Prefix PREFIX_FILTER_GPA_DEGREE = new Prefix(">deg"); public static final Prefix PREFIX_FILTER_EDUCATION = new Prefix("edu<"); public static final Prefix PREFIX_FILTER_EDUCATION_REVERSE = new Prefix(">edu"); @@ -42,6 +45,7 @@ public class CliSyntax { public static final SortWord SORTWORD_ENDORSEMENTS = new SortWord("endorsements"); public static final SortWord SORTWORD_ENDORSEMENT_NUMBER = new SortWord("endorsement number"); public static final SortWord SORTWORD_GPA = new SortWord("gpa"); + public static final SortWord SORTWORD_DEGREE = new SortWord("degree"); public static final SortWord SORTWORD_NAME = new SortWord("name"); public static final SortWord SORTWORD_POSITION_NUMBER = new SortWord("position number"); public static final SortWord SORTWORD_POSITIONS = new SortWord("positions"); @@ -49,6 +53,7 @@ public class CliSyntax { public static final SortWord SORTWORD_REVERSE_ENDORSEMENTS = new SortWord("reverse endorsements"); public static final SortWord SORTWORD_REVERSE_ENDORSEMENT_NUMBER = new SortWord("reverse endorsement number"); public static final SortWord SORTWORD_REVERSE_GPA = new SortWord("reverse gpa"); + public static final SortWord SORTWORD_REVERSE_DEGREE = new SortWord("reverse degree"); public static final SortWord SORTWORD_REVERSE_NAME = new SortWord("reverse name"); public static final SortWord SORTWORD_REVERSE_POSITION_NUMBER = new SortWord("reverse position number"); public static final SortWord SORTWORD_REVERSE_POSITIONS = new SortWord("reverse positions"); diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index 79ecb58bf81f..59fd8e82dabe 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -6,6 +6,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_EDUCATION; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_GPA; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DEGREE; 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_POS; @@ -40,7 +41,7 @@ public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_EDUCATION, - PREFIX_GPA, PREFIX_ADDRESS, PREFIX_SKILL, PREFIX_POS); + PREFIX_GPA, PREFIX_DEGREE, PREFIX_ADDRESS, PREFIX_SKILL, PREFIX_POS); Index index; @@ -65,6 +66,10 @@ public EditCommand parse(String args) throws ParseException { editPersonDescriptor.setGpa(ParserUtil.parseGpa(argMultimap.getValue(PREFIX_GPA).get())); } + if (argMultimap.getValue(PREFIX_DEGREE).isPresent()) { + editPersonDescriptor.setDegree(ParserUtil.parseDegree(argMultimap.getValue(PREFIX_DEGREE).get())); + } + if (argMultimap.getValue(PREFIX_EDUCATION).isPresent()) { editPersonDescriptor.setEducation(ParserUtil.parseEducation(argMultimap.getValue(PREFIX_EDUCATION).get())); } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index f4a9b7afbb5b..e4d8bb1806ab 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -9,12 +9,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.util.StringUtil; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Education; -import seedu.address.model.person.Email; -import seedu.address.model.person.Gpa; -import seedu.address.model.person.Name; -import seedu.address.model.person.Phone; +import seedu.address.model.person.*; import seedu.address.model.tag.SkillsTag; /** @@ -143,6 +138,21 @@ public static Education parseEducation(String education) throws ParseException { return new Education(trimmedEducation); } + /** + * Parses the degree field + * @param degree + * @return + * @throws ParseException + */ + public static Degree parseDegree(String degree) throws ParseException { + requireNonNull(degree); + String trimmedDegree = degree.trim(); + if (!Degree.isValidDegree(trimmedDegree)) { + throw new ParseException(Degree.MESSAGE_CONSTRAINTS); + } + return new Degree(trimmedDegree); + } + /** * Parses {@code Collection tags} into a {@code Set}. */ diff --git a/src/main/java/seedu/address/model/person/Degree.java b/src/main/java/seedu/address/model/person/Degree.java new file mode 100644 index 000000000000..e50a15524b70 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Degree.java @@ -0,0 +1,81 @@ +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a Person's name in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidDegree)} + */ +public class Degree { + + public static final String MESSAGE_CONSTRAINTS = + "Degree should be the highest level of completed education, and it should not be blank \n" + + "Can only be either: High school, Associates, Bachelors, Masters or PHD" ; + + /* + * The first character of the Degree must not be a whitespace, + * otherwise " " (a blank string) becomes a valid input. + */ + + //public static final String VALIDATION_REGEX = ; + + public final String value; + + /** + * Constructs a {@code Degree}. + * + * @param degree A valid degree. + */ + public Degree(String degree) { + requireNonNull(degree); + checkArgument(isValidDegree(degree), MESSAGE_CONSTRAINTS); + value = degree; + } + + /** + * Returns true if a given string is a valid name. + */ + public static boolean isValidDegree(String test) { + + if(test.equalsIgnoreCase("High School")){ + return true; + } + if(test.equalsIgnoreCase("Associates")){ + return true; + } + if(test.equalsIgnoreCase("Bachelors")){ + return true; + } + if(test.equalsIgnoreCase("Masters")){ + return true; + } + if(test.equalsIgnoreCase("PHD")){ + return true; + } + return false; + + } + + + @Override + public String toString() { + return value; + } + + //unsure if needed bc people can have the same??? + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Degree // instanceof handles nulls + && value.equals(((Degree) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} + + diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 55715ec3239b..dbef2514090f 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -25,6 +25,7 @@ public class Person { // new identity fields private final Education education; private final Gpa gpa; + private final Degree degree; //private final Skills skills; @@ -35,7 +36,7 @@ public class Person { /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Education education, Gpa gpa, Address address, + public Person(Name name, Phone phone, Email email, Education education, Gpa gpa, Degree degree, Address address, Set tags) { requireAllNonNull(name, phone, email, address, tags); @@ -44,6 +45,7 @@ public Person(Name name, Phone phone, Email email, Education education, Gpa gpa, this.email = email; this.education = education; this.gpa = gpa; + this.degree = degree; this.address = address; this.tags.addAll(tags); } @@ -68,6 +70,8 @@ public Gpa getGpa() { return gpa; } + public Degree getDegree() { return degree; } + public Address getAddress() { return address; } @@ -202,7 +206,7 @@ public boolean equals(Object other) { @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, education, address, tags); + return Objects.hash(name, phone, email, education, gpa, degree, address, tags); } @Override @@ -217,6 +221,8 @@ public String toString() { .append(getEducation()) .append(" Gpa: ") .append(getGpa()) + .append(" Degree: ") + .append(getDegree()) .append(" Address: ") .append(getAddress()) .append(" Tags: "); diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index db402a09de7a..bda415507c57 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -11,6 +11,7 @@ import seedu.address.model.person.Education; import seedu.address.model.person.Email; import seedu.address.model.person.Gpa; +import seedu.address.model.person.Degree; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -22,58 +23,58 @@ public class SampleDataUtil { public static Person[] getSamplePersons() { return new Person[] { - new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), - new Education("NUS"), new Gpa("3"), new Address("Blk 30 Geylang Street 29, #06-40"), - getTagSet(Arrays.asList("PHP", "Java", "Debugging", "C#", "Internet Protocols"), Arrays.asList( - "UI Developer", - "Advanced Graphics Designer"), Arrays.asList("Steve Jobs", "Mark Cuban"))), - new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), - new Education("NUS"), new Gpa("3"), new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), - getTagSet(Arrays.asList("HTML", "JavaScript", "C++", "Perl", "Linux", "Task Management"), - Arrays.asList("Front End Specialist", - "Software Engineer"), Arrays.asList("Mark Zuckerberg"))), - new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), - new Education("NUS"), new Gpa("3"), new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), - getTagSet(Arrays.asList("C++", "Java", "Swift", "Certificates", "Networking"), Arrays.asList( - "Cyber Crime "), - Arrays.asList("Barack Obama"))), - new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), - new Education("NUS"), new Gpa("3"), new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), - getTagSet(Arrays.asList("Python", "SQL", "Database Administration", "Project Management", - "Software Testing"), - Arrays.asList("Databases", "Systems " + "Analyst"), - Arrays.asList("Bill Gates", "Frederick Brooks"))), - new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), - new Education("NUS"), new Gpa("3"), new Address("Blk 47 Tampines Street 20, #17-35"), - getTagSet(Arrays.asList("Java", "JavaScript", "Excel", "Hadoop", "Market Analysis"), Arrays.asList( - "Software ", "Engineer", "Financial Analyst"), - Arrays.asList("Jeff Bezos", "Warren Buffett"))), - new Person(new Name("Susan McDonald"), new Phone("35810495"), new Email("susanM@gmail.com"), - new Education("Yale"), new Gpa("4"), new Address("32 Independence Way, New York NY"), - getTagSet(Arrays.asList("Java", "HTML", "CSS", "JavaScript", "Swift"), Arrays.asList("Front " - + "End Specialist", "UI Developer", "Project Manager"), Arrays.asList("Jeff Bezos"))), - new Person(new Name("Tony Stark"), new Phone("92874639"), new Email("tonys@avengers.com"), - new Education("MIT"), new Gpa("4"), new Address("911 Avengers Way, New York NY"), - getTagSet(Arrays.asList("Java", "Electrical Engineering", "MATLab", "Software Development", - "Leadership", "Presentation Skills"), Arrays.asList("Software Engineer", "Project Manager"), - Arrays.asList("Stan Lee"))), - new Person(new Name("Bruce Wayne"), new Phone("92875639"), new Email("bruce@wayne.com"), - new Education("Stanford"), new Gpa("4"), new Address("1 Wayne Manor, New York NY"), - getTagSet(Arrays.asList("Hardware Testing", "Business Analysis", "Finance", "Cyber Crime"), - Arrays.asList("Project Consultant", "Crime Analyst"), Arrays.asList("Thomas Wayne"))), - new Person(new Name("Peter Parker"), new Phone("92874339"), new Email("peterp@gmail.com"), - new Education("Brooklyn High School"), new Gpa("4"), new Address("99 Sunflower Dr, Brooklyn " - + "NY"), getTagSet(Arrays.asList("Electrical Engineering", "Java", "Python", - "Design", "Photography"), Arrays.asList("Advanced Graphics Designer", "Software " - + "Testing"), Arrays.asList("Stan Lee"))), - new Person(new Name("Claire Smith"), new Phone("98765432"), new Email("claireS@gmail.com"), - new Education("Oxford"), new Gpa("3"), new Address("12 Biscuits Way, Oxford"), - getTagSet(Arrays.asList("C#", "PHP", "Linux", "C++", "Finance"), Arrays.asList("Systems " - + "Analyst"), Arrays.asList("Elon Musk"))), - new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), - new Education("NUS"), new Gpa("3"), new Address("Blk 45 Aljunied Street 85, #11-31"), - getTagSet(Arrays.asList("Swift", "Java", "Linux", "Operating Systems", "Graphic Design", - "Hardware"), Arrays.asList("Project Consultant"), Arrays.asList("Steve Jobs"))) + new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), + new Education("NUS"), new Gpa("3.2"), new Degree("Bachelors"), new Address("Blk 30 Geylang Street 29, #06-40"), + getTagSet(Arrays.asList("PHP", "Java", "Debugging", "C#", "Internet Protocols"), Arrays.asList( + "UI Developer", + "Advanced Graphics Designer"), Arrays.asList("Steve Jobs", "Mark Cuban"))), + new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), + new Education("NUS"), new Gpa("3.5"),new Degree("Associates"), new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), + getTagSet(Arrays.asList("HTML", "JavaScript", "C++", "Perl", "Linux", "Task Management"), + Arrays.asList("Front End Specialist", + "Software Engineer"), Arrays.asList("Mark Zuckerberg"))), + new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), + new Education("NUS"), new Gpa("3.0"), new Degree("Bachelors"), new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), + getTagSet(Arrays.asList("C++", "Java", "Swift", "Certificates", "Networking"), Arrays.asList( + "Cyber Crime "), + Arrays.asList("Barack Obama"))), + new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), + new Education("NUS"), new Gpa("3"), new Degree("Bachelors"), new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), + getTagSet(Arrays.asList("Python", "SQL", "Database Administration", "Project Management", + "Software Testing"), + Arrays.asList("Databases", "Systems " + "Analyst"), + Arrays.asList("Bill Gates", "Frederick Brooks"))), + new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), + new Education("NUS"), new Gpa("4.0"), new Degree("Bachelors"), new Address("Blk 47 Tampines Street 20, #17-35"), + getTagSet(Arrays.asList("Java", "JavaScript", "Excel", "Hadoop", "Market Analysis"), Arrays.asList( + "Software ", "Engineer", "Financial Analyst"), + Arrays.asList("Jeff Bezos", "Warren Buffett"))), + new Person(new Name("Susan McDonald"), new Phone("35810495"), new Email("susanM@gmail.com"), + new Education("Yale"), new Gpa("4.0"), new Degree("Bachelors"), new Address("32 Independence Way, New York NY"), + getTagSet(Arrays.asList("Java", "HTML", "CSS", "JavaScript", "Swift"), Arrays.asList("Front " + + "End Specialist", "UI Developer", "Project Manager"), Arrays.asList("Jeff Bezos"))), + new Person(new Name("Tony Stark"), new Phone("92874639"), new Email("tonys@avengers.com"), + new Education("MIT"), new Gpa("4.0"), new Degree("PHD"), new Address("911 Avengers Way, New York NY"), + getTagSet(Arrays.asList("Java", "Electrical Engineering", "MATLab", "Software Development", + "Leadership", "Presentation Skills"), Arrays.asList("Software Engineer", "Project Manager"), + Arrays.asList("Stan Lee"))), + new Person(new Name("Bruce Wayne"), new Phone("92875639"), new Email("bruce@wayne.com"), + new Education("Stanford"), new Gpa("3.6"), new Degree("Bachelors"), new Address("1 Wayne Manor, New York NY"), + getTagSet(Arrays.asList("Hardware Testing", "Business Analysis", "Finance", "Cyber Crime"), + Arrays.asList("Project Consultant", "Crime Analyst"), Arrays.asList("Thomas Wayne"))), + new Person(new Name("Peter Parker"), new Phone("92874339"), new Email("peterp@gmail.com"), + new Education("Brooklyn High School"), new Gpa("2.0"), new Degree("High school"), new Address("99 Sunflower Dr, Brooklyn " + + "NY"), getTagSet(Arrays.asList("Electrical Engineering", "Java", "Python", + "Design", "Photography"), Arrays.asList("Advanced Graphics Designer", "Software " + + "Testing"), Arrays.asList("Stan Lee"))), + new Person(new Name("Claire Smith"), new Phone("98765432"), new Email("claireS@gmail.com"), + new Education("Oxford"), new Gpa("2.7"), new Degree("PHD"), new Address("12 Biscuits Way, Oxford"), + getTagSet(Arrays.asList("C#", "PHP", "Linux", "C++", "Finance"), Arrays.asList("Systems " + + "Analyst"), Arrays.asList("Elon Musk"))), + new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), + new Education("NUS"), new Gpa("2.1"), new Degree("Masters"), new Address("Blk 45 Aljunied Street 85, #11-31"), + getTagSet(Arrays.asList("Swift", "Java", "Linux", "Operating Systems", "Graphic Design", + "Hardware"), Arrays.asList("Project Consultant"), Arrays.asList("Steve Jobs"))) }; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index 5dfdfd0f3132..6035bdc9debf 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -14,6 +14,7 @@ import seedu.address.model.person.Education; import seedu.address.model.person.Email; import seedu.address.model.person.Gpa; +import seedu.address.model.person.Degree; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -31,6 +32,7 @@ class JsonAdaptedPerson { private final String email; private final String education; private final String gpa; + private final String degree; private final String address; private final List tagged = new ArrayList<>(); @@ -40,13 +42,14 @@ class JsonAdaptedPerson { @JsonCreator public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone, @JsonProperty("education") String education, @JsonProperty("gpa") String gpa, - @JsonProperty("email") String email, @JsonProperty("address") String address, - @JsonProperty("tagged") List tagged) { + @JsonProperty("degree") String degree, @JsonProperty("email") String email, + @JsonProperty("address") String address, @JsonProperty("tagged") List tagged) { this.name = name; this.phone = phone; this.email = email; this.education = education; this.gpa = gpa; + this.degree = degree; this.address = address; if (tagged != null) { this.tagged.addAll(tagged); @@ -62,6 +65,7 @@ public JsonAdaptedPerson(Person source) { email = source.getEmail().value; education = source.getEducation().university; gpa = source.getGpa().value; + degree = source.getDegree().value; address = source.getAddress().value; tagged.addAll(source.getTags().stream() .map(JsonAdaptedTag::new) @@ -104,7 +108,8 @@ public Person toModelType() throws IllegalValueException { final Email modelEmail = new Email(email); if (gpa == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Gpa.class.getSimpleName())); + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, + Gpa.class.getSimpleName())); } if (!Gpa.isValidGpa(gpa)) { throw new IllegalValueException(Phone.MESSAGE_CONSTRAINTS); @@ -120,6 +125,15 @@ public Person toModelType() throws IllegalValueException { } final Education modelEducation = new Education(education); + if (degree == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, + Degree.class.getSimpleName())); + } + if (!Degree.isValidDegree(degree)) { + throw new IllegalValueException(Name.MESSAGE_CONSTRAINTS); + } + final Degree modelDegree = new Degree(degree); + if (address == null) { throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName())); @@ -129,7 +143,7 @@ public Person toModelType() throws IllegalValueException { } final Address modelAddress = new Address(address); final Set modelTags = new HashSet<>(personTags); - return new Person(modelName, modelPhone, modelEmail, modelEducation, modelGpa, modelAddress, modelTags); + return new Person(modelName, modelPhone, modelEmail, modelEducation, modelGpa, modelDegree, modelAddress, modelTags); } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index de2311e1c7bf..2c97c2fb252c 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -37,6 +37,12 @@ public class PersonCard extends UiPart { @FXML private Label email; @FXML + private Label education; + @FXML + private Label gpa; + @FXML + private Label degree; + @FXML private FlowPane tags; public PersonCard(Person person, int displayedIndex) { @@ -47,6 +53,9 @@ public PersonCard(Person person, int displayedIndex) { phone.setText(person.getPhone().value); address.setText(person.getAddress().value); email.setText(person.getEmail().value); + education.setText(person.getEducation().university); + gpa.setText(person.getGpa().value); + degree.setText(person.getDegree().value); //person.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); formatTags(person); } diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index f08ea32ad558..1a8555af3fd3 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -31,6 +31,9 @@