From 5d62dafa54eab441f7cd0151ff1a5166055c2cbd Mon Sep 17 00:00:00 2001 From: Sarah Chua Date: Mon, 17 Feb 2020 14:55:31 +0800 Subject: [PATCH 001/595] test-commit --- README.adoc | 2 ++ src/main/main.iml | 11 +++++++++++ src/test/test.iml | 12 ++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 src/main/main.iml create mode 100644 src/test/test.iml diff --git a/README.adoc b/README.adoc index e36efe534bb..462d9a23f51 100644 --- a/README.adoc +++ b/README.adoc @@ -1,6 +1,8 @@ = Address Book (Level 3) ifdef::env-github,env-browser[:relfileprefix: docs/] +* Done by W14-3 + https://travis-ci.org/se-edu/addressbook-level3[image:https://travis-ci.org/se-edu/addressbook-level3.svg?branch=master[Build Status]] https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] https://coveralls.io/github/se-edu/addressbook-level3?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level3/badge.svg?branch=master[Coverage Status]] diff --git a/src/main/main.iml b/src/main/main.iml new file mode 100644 index 00000000000..908ad4f521a --- /dev/null +++ b/src/main/main.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/test.iml b/src/test/test.iml new file mode 100644 index 00000000000..5ebc6f48ecb --- /dev/null +++ b/src/test/test.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file From 35d9af3c06650c4c994f3febffe335575c00be00 Mon Sep 17 00:00:00 2001 From: Sarah Chua Date: Mon, 17 Feb 2020 15:41:13 +0800 Subject: [PATCH 002/595] Set up Travis CI --- README.adoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index 462d9a23f51..e54bac0d5a4 100644 --- a/README.adoc +++ b/README.adoc @@ -3,9 +3,10 @@ ifdef::env-github,env-browser[:relfileprefix: docs/] * Done by W14-3 -https://travis-ci.org/se-edu/addressbook-level3[image:https://travis-ci.org/se-edu/addressbook-level3.svg?branch=master[Build Status]] + +https://travis-ci.org/AY1920S2-CS2103-W14-3/main[image:https://travis-ci.org/AY1920S2-CS2103-W14-3/main.svg?branch=master[Build Status]] https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] -https://coveralls.io/github/se-edu/addressbook-level3?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level3/badge.svg?branch=master[Coverage Status]] +https://coveralls.io/github/AY1920S2-CS2103-W14-3/main?branch=master[image:https://coveralls.io/repos/github/AY1920S2-CS2103-W14-3/main/badge.svg?branch=master[Coverage Status]] https://www.codacy.com/app/damith/addressbook-level3?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level3&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]] From cd7f4bd607779955266ae92e5b276f4709d27ab2 Mon Sep 17 00:00:00 2001 From: Sarah Chua Date: Mon, 17 Feb 2020 15:50:01 +0800 Subject: [PATCH 003/595] Remove Codacy badge --- README.adoc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.adoc b/README.adoc index e54bac0d5a4..755051095f4 100644 --- a/README.adoc +++ b/README.adoc @@ -10,14 +10,6 @@ https://coveralls.io/github/AY1920S2-CS2103-W14-3/main?branch=master[image:https https://www.codacy.com/app/damith/addressbook-level3?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level3&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]] -ifdef::env-github[] -image::docs/images/Ui.png[width="600"] -endif::[] - -ifndef::env-github[] -image::images/Ui.png[width="600"] -endif::[] - * This is a desktop Address Book application. It has a GUI but most of the user interactions happen using a CLI (Command Line Interface). * It is a Java sample application intended for students learning Software Engineering while using Java as the main programming language. * It is *written in OOP fashion*. It provides a *reasonably well-written* code example that is *significantly bigger* (around 6 KLoC)than what students usually write in beginner-level SE modules. From 6b794c77d7fd74fd979749b3dd6c452e7f9c100c Mon Sep 17 00:00:00 2001 From: Sarah Chua Date: Mon, 17 Feb 2020 16:02:24 +0800 Subject: [PATCH 004/595] test-1 --- README.adoc | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.adoc b/README.adoc index 755051095f4..f2722fd96a3 100644 --- a/README.adoc +++ b/README.adoc @@ -1,9 +1,6 @@ = Address Book (Level 3) ifdef::env-github,env-browser[:relfileprefix: docs/] -* Done by W14-3 - - https://travis-ci.org/AY1920S2-CS2103-W14-3/main[image:https://travis-ci.org/AY1920S2-CS2103-W14-3/main.svg?branch=master[Build Status]] https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] https://coveralls.io/github/AY1920S2-CS2103-W14-3/main?branch=master[image:https://coveralls.io/repos/github/AY1920S2-CS2103-W14-3/main/badge.svg?branch=master[Coverage Status]] From 22eee0f11ca394268f83fc6cf013bb3086f56f47 Mon Sep 17 00:00:00 2001 From: Sarah Chua Date: Mon, 17 Feb 2020 16:06:32 +0800 Subject: [PATCH 005/595] test-2 --- README.adoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.adoc b/README.adoc index f2722fd96a3..a3d38b30f7a 100644 --- a/README.adoc +++ b/README.adoc @@ -6,6 +6,13 @@ https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appv https://coveralls.io/github/AY1920S2-CS2103-W14-3/main?branch=master[image:https://coveralls.io/repos/github/AY1920S2-CS2103-W14-3/main/badge.svg?branch=master[Coverage Status]] https://www.codacy.com/app/damith/addressbook-level3?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level3&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]] +ifdef::env-github[] +image::docs/images/Ui.png[width="600"] +endif::[] + +ifndef::env-github[] +image::images/Ui.png[width="600"] +endif::[] * This is a desktop Address Book application. It has a GUI but most of the user interactions happen using a CLI (Command Line Interface). * It is a Java sample application intended for students learning Software Engineering while using Java as the main programming language. From ed7dda94af532b6d044506267f9fce71bca0a240 Mon Sep 17 00:00:00 2001 From: Sarah Chua Date: Mon, 17 Feb 2020 16:11:55 +0800 Subject: [PATCH 006/595] test-3 --- src/main/main.iml | 2 +- src/test/test.iml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/main.iml b/src/main/main.iml index 908ad4f521a..b89a3f5b0a6 100644 --- a/src/main/main.iml +++ b/src/main/main.iml @@ -8,4 +8,4 @@ - \ No newline at end of file + diff --git a/src/test/test.iml b/src/test/test.iml index 5ebc6f48ecb..6e30bb1c613 100644 --- a/src/test/test.iml +++ b/src/test/test.iml @@ -9,4 +9,4 @@ - \ No newline at end of file + From 38ff8c95dc8e7ac396c9a72a060ba9b70fc0522c Mon Sep 17 00:00:00 2001 From: Elysia Tan <> Date: Thu, 20 Feb 2020 09:59:48 +0800 Subject: [PATCH 007/595] Imported gradle project --- src/main/main.iml | 7 ++++++- src/test/test.iml | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/main.iml b/src/main/main.iml index b89a3f5b0a6..3419523086a 100644 --- a/src/main/main.iml +++ b/src/main/main.iml @@ -4,8 +4,13 @@ + + + + + - + \ No newline at end of file diff --git a/src/test/test.iml b/src/test/test.iml index 6e30bb1c613..bb46440c32d 100644 --- a/src/test/test.iml +++ b/src/test/test.iml @@ -8,5 +8,6 @@ + - + \ No newline at end of file From d50db7acd0762e809e3304dbff33ff5169751a8b Mon Sep 17 00:00:00 2001 From: Elysia Tan <> Date: Thu, 20 Feb 2020 13:57:26 +0800 Subject: [PATCH 008/595] Enabled jUnit --- src/test/test.iml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/test.iml b/src/test/test.iml index bb46440c32d..ce863a5a1ca 100644 --- a/src/test/test.iml +++ b/src/test/test.iml @@ -9,5 +9,22 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file From e243803ae3cb34c726f3b82e4f5ecf178eab1426 Mon Sep 17 00:00:00 2001 From: KwanXinJie Date: Wed, 26 Feb 2020 20:04:42 +0800 Subject: [PATCH 009/595] add command --- .../address/logic/commands/EditCommand.java | 4 +- .../address/logic/commands/RemarkCommand.java | 86 ++++++++++++ .../logic/parser/AddCommandParser.java | 4 +- .../logic/parser/AddressBookParser.java | 4 + .../seedu/address/logic/parser/CliSyntax.java | 2 +- .../logic/parser/RemarkCommandParser.java | 36 +++++ .../seedu/address/model/person/Person.java | 10 +- .../seedu/address/model/person/Remark.java | 33 +++++ .../address/model/util/SampleDataUtil.java | 16 ++- .../address/storage/JsonAdaptedPerson.java | 13 +- .../java/seedu/address/ui/PersonCard.java | 3 + src/main/resources/view/PersonListCard.fxml | 1 + .../duplicatePersonAddressBook.json | 4 +- .../typicalPersonsAddressBook.json | 7 + .../logic/commands/CommandTestUtil.java | 2 + .../logic/commands/RemarkCommandTest.java | 128 ++++++++++++++++++ .../storage/JsonAdaptedPersonTest.java | 23 ++-- .../seedu/address/testutil/PersonBuilder.java | 17 ++- .../address/testutil/TypicalPersons.java | 4 +- 19 files changed, 372 insertions(+), 25 deletions(-) create mode 100644 src/main/java/seedu/address/logic/commands/RemarkCommand.java create mode 100644 src/main/java/seedu/address/logic/parser/RemarkCommandParser.java create mode 100644 src/main/java/seedu/address/model/person/Remark.java create mode 100644 src/test/java/seedu/address/logic/commands/RemarkCommandTest.java diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 7e36114902f..71a993475e6 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -25,6 +25,7 @@ import seedu.address.model.person.Person; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; +import seedu.address.model.person.Remark; /** * Edits the details of an existing person in the address book. @@ -97,9 +98,10 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); + Remark updatedRemark = personToEdit.getRemark(); // edit command does not allow editing remarks Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); + return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedRemark, updatedTags); } @Override diff --git a/src/main/java/seedu/address/logic/commands/RemarkCommand.java b/src/main/java/seedu/address/logic/commands/RemarkCommand.java new file mode 100644 index 00000000000..0acc9d5e30c --- /dev/null +++ b/src/main/java/seedu/address/logic/commands/RemarkCommand.java @@ -0,0 +1,86 @@ +package seedu.address.logic.commands; +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import java.util.List; +import seedu.address.commons.core.Messages; +import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.person.Person; +import seedu.address.model.person.Remark; + +/** + * Changes the remark of an existing person in the address book. + */ +public class RemarkCommand extends Command{ + public static final String COMMAND_WORD = "remark"; + public static final String MESSAGE_ARGUMENTS = "Index: %1$d, Remark: %2$s"; + private final Index index; + private final Remark remark; + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the remark of the person identified " + + "by the index number used in the last person listing. " + + "Existing remark will be overwritten by the input.\n" + + "Parameters: INDEX (must be a positive integer) " + + "r/ [REMARK]\n" + + "Example: " + COMMAND_WORD + " 1 " + + "r/ Likes to swim."; + public static final String MESSAGE_ADD_REMARK_SUCCESS = "Added remark to Person: %1$s"; + public static final String MESSAGE_DELETE_REMARK_SUCCESS = "Removed remark from Person: %1$s"; + + /** + * @param index of the person in the filtered person list to edit the remark + * @param remark of the person to be updated to + */ + public RemarkCommand(Index index, Remark remark) { + requireAllNonNull(index, remark); + + this.index = index; + this.remark = remark; + } + + @Override + public CommandResult execute(Model model) throws CommandException { + List lastShownList = model.getFilteredPersonList(); + + if (index.getZeroBased() >= lastShownList.size()) { + throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + } + + Person personToEdit = lastShownList.get(index.getZeroBased()); + Person editedPerson = new Person(personToEdit.getName(), personToEdit.getPhone(), personToEdit.getEmail(), + personToEdit.getAddress(), remark, personToEdit.getTags()); + + model.setPerson(personToEdit, editedPerson); + model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + + return new CommandResult(generateSuccessMessage(editedPerson)); + } + + /** + * Generates a command execution success message based on whether the remark is added to or removed from + * {@code personToEdit}. + */ + private String generateSuccessMessage(Person personToEdit) { + String message = !remark.value.isEmpty() ? MESSAGE_ADD_REMARK_SUCCESS : MESSAGE_DELETE_REMARK_SUCCESS; + return String.format(message, personToEdit); + } + + @Override + public boolean equals(Object other) { + // short circuit if same object + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof RemarkCommand)) { + return false; + } + + // state check + RemarkCommand e = (RemarkCommand) other; + return index.equals(e.index) + && remark.equals(e.remark); + } +} diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 3b8bfa035e8..c7d0f809928 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -17,6 +17,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Remark; import seedu.address.model.tag.Tag; /** @@ -42,9 +43,10 @@ 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()); + Remark remark = new Remark(""); // add command does not allow adding remarks straight away Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - Person person = new Person(name, phone, email, address, tagList); + Person person = new Person(name, phone, email, address, remark, tagList); return new AddCommand(person); } diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 1e466792b46..eff2d21e832 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -15,6 +15,7 @@ import seedu.address.logic.commands.FindCommand; import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCommand; +import seedu.address.logic.commands.RemarkCommand; import seedu.address.logic.parser.exceptions.ParseException; /** @@ -59,6 +60,9 @@ public Command parseCommand(String userInput) throws ParseException { case FindCommand.COMMAND_WORD: return new FindCommandParser().parse(arguments); + case RemarkCommand.COMMAND_WORD: + return new RemarkCommandParser().parse(arguments); + case ListCommand.COMMAND_WORD: return new ListCommand(); diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 75b1a9bf119..798f15d2d81 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -11,5 +11,5 @@ 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_TAG = new Prefix("t/"); - + public static final Prefix PREFIX_REMARK = new Prefix("r/"); } diff --git a/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java b/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java new file mode 100644 index 00000000000..24ac864022d --- /dev/null +++ b/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java @@ -0,0 +1,36 @@ +package seedu.address.logic.parser; +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; +import seedu.address.commons.core.index.Index; +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.logic.commands.RemarkCommand; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.person.Remark; + +/** + * Parses input arguments and creates a new {@code RemarkCommand} object + */ +public class RemarkCommandParser implements Parser { + /** + * Parses the given {@code String} of arguments in the context of the {@code RemarkCommand} + * and returns a {@code RemarkCommand} object for execution. + * @throws ParseException if the user input does not conform the expected format + */ + public RemarkCommand parse(String args) throws ParseException { + requireNonNull(args); + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_REMARK); + + Index index; + try { + index = ParserUtil.parseIndex(argMultimap.getPreamble()); + } catch (IllegalValueException ive) { + throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, + RemarkCommand.MESSAGE_USAGE), ive); + } + + String remark = argMultimap.getValue(PREFIX_REMARK).orElse(""); + + return new RemarkCommand(index, new Remark(remark)); + } +} diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 557a7a60cd5..610adea97cc 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -22,17 +22,19 @@ public class Person { // Data fields private final Address address; + private final Remark remark; private final Set tags = new HashSet<>(); /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Address address, Set tags) { + public Person(Name name, Phone phone, Email email, Address address, Remark remark, Set tags) { requireAllNonNull(name, phone, email, address, tags); this.name = name; this.phone = phone; this.email = email; this.address = address; + this.remark = remark; this.tags.addAll(tags); } @@ -52,6 +54,10 @@ public Address getAddress() { return address; } + public Remark getRemark() { + return remark; + } + /** * Returns an immutable tag set, which throws {@code UnsupportedOperationException} * if modification is attempted. @@ -112,6 +118,8 @@ public String toString() { .append(getEmail()) .append(" Address: ") .append(getAddress()) + .append(" Remark: ") + .append(getRemark()) .append(" Tags: "); getTags().forEach(builder::append); return builder.toString(); diff --git a/src/main/java/seedu/address/model/person/Remark.java b/src/main/java/seedu/address/model/person/Remark.java new file mode 100644 index 00000000000..c8fd1193895 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Remark.java @@ -0,0 +1,33 @@ +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; + +/** + * Represents a Person's remark in the address book. + * Guarantees: immutable; is always valid + */ +public class Remark { + public final String value; + + public Remark(String remark) { + requireNonNull(remark); + value = remark; + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Remark // instanceof handles nulls + && value.equals(((Remark) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} \ No newline at end of file diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 1806da4facf..a1dbb9411b2 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -11,31 +11,35 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Remark; import seedu.address.model.tag.Tag; /** * Contains utility methods for populating {@code AddressBook} with sample data. */ public class SampleDataUtil { + + public static final Remark EMPTY_REMARK = new Remark(""); + public static Person[] getSamplePersons() { return new Person[] { new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), - new Address("Blk 30 Geylang Street 29, #06-40"), + new Address("Blk 30 Geylang Street 29, #06-40"), EMPTY_REMARK, getTagSet("friends")), new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), - new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), + new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), EMPTY_REMARK, getTagSet("colleagues", "friends")), new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), - new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), + new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), EMPTY_REMARK, getTagSet("neighbours")), new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), - new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), + new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), EMPTY_REMARK, getTagSet("family")), new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), - new Address("Blk 47 Tampines Street 20, #17-35"), + new Address("Blk 47 Tampines Street 20, #17-35"), EMPTY_REMARK, getTagSet("classmates")), new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), - new Address("Blk 45 Aljunied Street 85, #11-31"), + new Address("Blk 45 Aljunied Street 85, #11-31"), EMPTY_REMARK, getTagSet("colleagues")) }; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index a6321cec2ea..fa0762d30ee 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -15,6 +15,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Remark; import seedu.address.model.tag.Tag; /** @@ -28,6 +29,7 @@ class JsonAdaptedPerson { private final String phone; private final String email; private final String address; + private final String remark; private final List tagged = new ArrayList<>(); /** @@ -36,11 +38,12 @@ class JsonAdaptedPerson { @JsonCreator public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone, @JsonProperty("email") String email, @JsonProperty("address") String address, - @JsonProperty("tagged") List tagged) { + @JsonProperty("remark") String remark, @JsonProperty("tagged") List tagged) { this.name = name; this.phone = phone; this.email = email; this.address = address; + this.remark = remark; if (tagged != null) { this.tagged.addAll(tagged); } @@ -54,6 +57,7 @@ public JsonAdaptedPerson(Person source) { phone = source.getPhone().value; email = source.getEmail().value; address = source.getAddress().value; + remark = source.getRemark().value; tagged.addAll(source.getTags().stream() .map(JsonAdaptedTag::new) .collect(Collectors.toList())); @@ -102,8 +106,13 @@ public Person toModelType() throws IllegalValueException { } final Address modelAddress = new Address(address); + if (remark == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Remark.class.getSimpleName())); + } + final Remark modelRemark = new Remark(remark); + final Set modelTags = new HashSet<>(personTags); - return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags); + return new Person(modelName, modelPhone, modelEmail, modelAddress, modelRemark, modelTags); } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 0684b088868..34350442ebd 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -40,6 +40,8 @@ public class PersonCard extends UiPart { private Label email; @FXML private FlowPane tags; + @FXML + private Label remark; public PersonCard(Person person, int displayedIndex) { super(FXML); @@ -49,6 +51,7 @@ public PersonCard(Person person, int displayedIndex) { phone.setText(person.getPhone().value); address.setText(person.getAddress().value); email.setText(person.getEmail().value); + remark.setText(person.getRemark().value); person.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index f08ea32ad55..d1a7eb614f8 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -31,6 +31,7 @@