diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 4abb17e3e..bec5fc8b2 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -35,7 +35,7 @@ Please refer to the <> section to learn h What's different from AddressBook-Level1: * Support for storing address (`a/`) and tags (`t/`) -* Support for marking a contact detail as 'private' (`pa/`) (`pe/`) (`pp/`) +* Support for marking a contact detail as 'private' (`pa/`) (`pe/`) (`pp/`) (`pm/`) * View details of a person (`view` : shows non-private details), (`viewall` : shows all details) == Viewing help : `help` @@ -50,13 +50,13 @@ Help is also shown if you enter an incorrect command e.g. `abcd` == Adding a person: `add` Adds a person to the address book. + -Format: `add NAME [p]p/PHONE_NUMBER [p]e/EMAIL [p]a/ADDRESS [t/TAG]...` +Format: `add NAME [p]p/PHONE_NUMBER [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]...` **** Words in `UPPER_CASE` are the parameters, items in `SQUARE_BRACKETS` are optional, items with `...` after them can have multiple instances. Order of parameters are fixed. -Put a `p` before the phone / email / address prefixes to mark it as `private`. `private` details can only +Put a `p` before the phone / email / address / major prefixes to mark it as `private`. `private` details can only be seen using the `viewall` command. Persons can have any number of tags (including 0). @@ -65,7 +65,7 @@ Persons can have any number of tags (including 0). Examples: * `add John Doe p/98765432 e/johnd@gmail.com a/John street, block 123, #01-01` -* `add Betsy Crowe pp/1234567 e/betsycrowe@gmail.com pa/Newgate Prison t/criminal t/friend` +* `add Betsy Crowe pp/1234567 e/betsycrowe@gmail.com pa/Newgate Prison m/CS t/criminal t/friend` == Listing all persons : `list` diff --git a/src/seedu/addressbook/commands/AddCommand.java b/src/seedu/addressbook/commands/AddCommand.java index ac307f1b2..d1f5b6269 100644 --- a/src/seedu/addressbook/commands/AddCommand.java +++ b/src/seedu/addressbook/commands/AddCommand.java @@ -6,6 +6,7 @@ import seedu.addressbook.data.exception.IllegalValueException; import seedu.addressbook.data.person.Address; import seedu.addressbook.data.person.Email; +import seedu.addressbook.data.person.Major; import seedu.addressbook.data.person.Name; import seedu.addressbook.data.person.Person; import seedu.addressbook.data.person.Phone; @@ -22,9 +23,9 @@ public class AddCommand extends Command { public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " + "Contact details can be marked private by prepending 'p' to the prefix.\n" - + "Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...\n" + + "Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]...\n" + "Example: " + COMMAND_WORD - + " John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney"; + + " John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney"; public static final String MESSAGE_SUCCESS = "New person added: %1$s"; public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; @@ -40,6 +41,7 @@ public AddCommand(String name, String phone, boolean isPhonePrivate, String email, boolean isEmailPrivate, String address, boolean isAddressPrivate, + String major, boolean isMajorPrivate, Set tags) throws IllegalValueException { final Set tagSet = new HashSet<>(); for (String tagName : tags) { @@ -50,6 +52,7 @@ public AddCommand(String name, new Phone(phone, isPhonePrivate), new Email(email, isEmailPrivate), new Address(address, isAddressPrivate), + new Major(major, isMajorPrivate), tagSet ); } diff --git a/src/seedu/addressbook/commands/Command.java b/src/seedu/addressbook/commands/Command.java index 2ff8f1575..c5d76eeff 100644 --- a/src/seedu/addressbook/commands/Command.java +++ b/src/seedu/addressbook/commands/Command.java @@ -39,9 +39,11 @@ public static String getMessageForPersonListShownSummary(List relevantPersons; public CommandResult(String feedbackToUser) { diff --git a/src/seedu/addressbook/commands/HelpCommand.java b/src/seedu/addressbook/commands/HelpCommand.java index 9be217d89..8c71365c5 100644 --- a/src/seedu/addressbook/commands/HelpCommand.java +++ b/src/seedu/addressbook/commands/HelpCommand.java @@ -15,14 +15,14 @@ public class HelpCommand extends Command { public CommandResult execute() { return new CommandResult( AddCommand.MESSAGE_USAGE - + "\n" + DeleteCommand.MESSAGE_USAGE - + "\n" + ClearCommand.MESSAGE_USAGE - + "\n" + FindCommand.MESSAGE_USAGE - + "\n" + ListCommand.MESSAGE_USAGE - + "\n" + ViewCommand.MESSAGE_USAGE - + "\n" + ViewAllCommand.MESSAGE_USAGE - + "\n" + HelpCommand.MESSAGE_USAGE - + "\n" + ExitCommand.MESSAGE_USAGE + + "\n" + DeleteCommand.MESSAGE_USAGE + + "\n" + ClearCommand.MESSAGE_USAGE + + "\n" + FindCommand.MESSAGE_USAGE + + "\n" + ListCommand.MESSAGE_USAGE + + "\n" + ViewCommand.MESSAGE_USAGE + + "\n" + ViewAllCommand.MESSAGE_USAGE + + "\n" + HelpCommand.MESSAGE_USAGE + + "\n" + ExitCommand.MESSAGE_USAGE ); } } diff --git a/src/seedu/addressbook/data/AddressBook.java b/src/seedu/addressbook/data/AddressBook.java index 537d35c89..a70858fa0 100644 --- a/src/seedu/addressbook/data/AddressBook.java +++ b/src/seedu/addressbook/data/AddressBook.java @@ -72,6 +72,6 @@ public UniquePersonList getAllPersons() { public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof AddressBook // instanceof handles nulls - && this.allPersons.equals(((AddressBook) other).allPersons)); + && this.allPersons.equals(((AddressBook) other).allPersons)); } } diff --git a/src/seedu/addressbook/data/person/Major.java b/src/seedu/addressbook/data/person/Major.java new file mode 100644 index 000000000..522b691eb --- /dev/null +++ b/src/seedu/addressbook/data/person/Major.java @@ -0,0 +1,59 @@ +package seedu.addressbook.data.person; + +import seedu.addressbook.data.exception.IllegalValueException; + +/** + * Represents a Person's major in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidMajor(String)} + */ +public class Major { + + public static final String EXAMPLE = "Computing"; + public static final String MESSAGE_MAJOR_CONSTRAINTS = "Person addresses can be in any format"; + public static final String MAJOR_VALIDATION_REGEX = ".+"; + + public final String value; + private boolean isPrivate; + + /** + * Validates given major. + * + * @throws IllegalValueException if given major string is invalid. + */ + public Major(String major, boolean isPrivate) throws IllegalValueException { + this.isPrivate = isPrivate; + String trimmedMajor = major.trim(); + if (!isValidMajor(trimmedMajor)) { + throw new IllegalValueException(MESSAGE_MAJOR_CONSTRAINTS); + } + this.value = trimmedMajor; + } + + /** + * Returns true if the given string is a valid person major. + */ + public static boolean isValidMajor(String test) { + return test.matches(MAJOR_VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Major // instanceof handles nulls + && this.value.equals(((Major) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + public boolean isPrivate() { + return isPrivate; + } +} diff --git a/src/seedu/addressbook/data/person/Person.java b/src/seedu/addressbook/data/person/Person.java index 64551c7fe..34d21cda3 100644 --- a/src/seedu/addressbook/data/person/Person.java +++ b/src/seedu/addressbook/data/person/Person.java @@ -16,17 +16,19 @@ public class Person implements ReadOnlyPerson { private Phone phone; private Email email; private Address address; + private Major major; private final Set tags = new HashSet<>(); /** * Assumption: 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, Major major, Set tags) { this.name = name; this.phone = phone; this.email = email; this.address = address; + this.major = major; this.tags.addAll(tags); } @@ -34,7 +36,7 @@ public Person(Name name, Phone phone, Email email, Address address, Set tag * Copy constructor. */ public Person(ReadOnlyPerson source) { - this(source.getName(), source.getPhone(), source.getEmail(), source.getAddress(), source.getTags()); + this(source.getName(), source.getPhone(), source.getEmail(), source.getAddress(), source.getMajor(),source.getTags()); } @Override @@ -53,9 +55,10 @@ public Email getEmail() { } @Override - public Address getAddress() { - return address; - } + public Address getAddress() { return address; } + + @Override + public Major getMajor() { return major; } @Override public Set getTags() { @@ -80,7 +83,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, address, tags); + return Objects.hash(name, phone, email, address, major, tags); } @Override diff --git a/src/seedu/addressbook/data/person/ReadOnlyPerson.java b/src/seedu/addressbook/data/person/ReadOnlyPerson.java index 1493f0a2b..291394465 100644 --- a/src/seedu/addressbook/data/person/ReadOnlyPerson.java +++ b/src/seedu/addressbook/data/person/ReadOnlyPerson.java @@ -14,6 +14,7 @@ public interface ReadOnlyPerson { Phone getPhone(); Email getEmail(); Address getAddress(); + Major getMajor(); /** * Returns a new TagSet that is a deep copy of the internal TagSet, @@ -42,6 +43,7 @@ default boolean hasSameData(ReadOnlyPerson other) { && other.getPhone().equals(this.getPhone()) && other.getEmail().equals(this.getEmail()) && other.getAddress().equals(this.getAddress()) + && other.getMajor().equals(this.getMajor()) && other.getTags().equals(this.getTags())); } @@ -67,6 +69,11 @@ default String getAsTextShowAll() { builder.append(detailIsPrivate); } builder.append(getAddress()) + .append(" Major: "); + if (getMajor().isPrivate()) { + builder.append(detailIsPrivate); + } + builder.append(getMajor()) .append(" Tags: "); for (Tag tag : getTags()) { builder.append(tag); @@ -89,6 +96,9 @@ default String getAsTextHidePrivate() { if (!getAddress().isPrivate()) { builder.append(" Address: ").append(getAddress()); } + if (!getMajor().isPrivate()) { + builder.append(" Major: ").append(getMajor()); + } builder.append(" Tags: "); for (Tag tag : getTags()) { builder.append(tag); diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index abddb3f45..127f62289 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -39,6 +39,7 @@ public class Parser { + " (?p?)p/(?[^/]+)" + " (?p?)e/(?[^/]+)" + " (?p?)a/(?
[^/]+)" + + " (?p?)m/(?[^/]+)" + "(?(?: t/[^/]+)*)"); // variable number of tags @@ -128,6 +129,9 @@ private Command prepareAdd(String args) { matcher.group("address"), isPrivatePrefixPresent(matcher.group("isAddressPrivate")), + matcher.group("major"), + isPrivatePrefixPresent(matcher.group("isMajorPrivate")), + getTagsFromArgs(matcher.group("tagArguments")) ); } catch (IllegalValueException ive) { @@ -217,7 +221,7 @@ private Command prepareViewAll(String args) { * * @param args arguments string to parse as index number * @return the parsed index number - * @throws ParseException if no region of the args string could be found for the index + * @throws ParseException if no region of the args string could be found for the index * @throws NumberFormatException the args string region is not a valid number */ private int parseArgsAsDisplayedIndex(String args) throws ParseException, NumberFormatException { diff --git a/src/seedu/addressbook/storage/AddressBookDecoder.java b/src/seedu/addressbook/storage/AddressBookDecoder.java index b277f18a3..15c406101 100644 --- a/src/seedu/addressbook/storage/AddressBookDecoder.java +++ b/src/seedu/addressbook/storage/AddressBookDecoder.java @@ -13,6 +13,7 @@ import seedu.addressbook.data.exception.IllegalValueException; import seedu.addressbook.data.person.Address; import seedu.addressbook.data.person.Email; +import seedu.addressbook.data.person.Major; import seedu.addressbook.data.person.Name; import seedu.addressbook.data.person.Person; import seedu.addressbook.data.person.Phone; @@ -28,7 +29,7 @@ public class AddressBookDecoder { /** * Decodes {@code encodedAddressBook} into an {@code AddressBook} containing the decoded persons. * - * @throws IllegalValueException if any of the fields in any encoded person string is invalid. + * @throws IllegalValueException if any of the fields in any encoded person string is invalid. * @throws StorageOperationException if the {@code encodedAddressBook} is in an invalid format. */ public static AddressBook decodeAddressBook(List encodedAddressBook) @@ -43,7 +44,7 @@ public static AddressBook decodeAddressBook(List encodedAddressBook) /** * Decodes {@code encodedPerson} into a {@code Person}. * - * @throws IllegalValueException if any field in the {@code encodedPerson} is invalid. + * @throws IllegalValueException if any field in the {@code encodedPerson} is invalid. * @throws StorageOperationException if {@code encodedPerson} is in an invalid format. */ private static Person decodePersonFromString(String encodedPerson) @@ -58,6 +59,7 @@ private static Person decodePersonFromString(String encodedPerson) new Phone(matcher.group("phone"), isPrivatePrefixPresent(matcher.group("isPhonePrivate"))), new Email(matcher.group("email"), isPrivatePrefixPresent(matcher.group("isEmailPrivate"))), new Address(matcher.group("address"), isPrivatePrefixPresent(matcher.group("isAddressPrivate"))), + new Major(matcher.group("major"), isPrivatePrefixPresent(matcher.group("isMajorPrivate"))), getTagsFromEncodedPerson(matcher.group("tagArguments")) ); } diff --git a/src/seedu/addressbook/storage/AddressBookEncoder.java b/src/seedu/addressbook/storage/AddressBookEncoder.java index 8cb206a8a..bf2adceb0 100644 --- a/src/seedu/addressbook/storage/AddressBookEncoder.java +++ b/src/seedu/addressbook/storage/AddressBookEncoder.java @@ -38,6 +38,9 @@ private static String encodePersonToString(Person person) { encodedPersonBuilder.append(person.getAddress().isPrivate() ? " p" : " "); encodedPersonBuilder.append("a/").append(person.getAddress().value); + encodedPersonBuilder.append(person.getMajor().isPrivate() ? " p" : " "); + encodedPersonBuilder.append("m/").append(person.getMajor().value); + person.getTags().forEach(tag -> encodedPersonBuilder.append(" t/").append(tag.tagName)); return encodedPersonBuilder.toString(); diff --git a/src/seedu/addressbook/storage/StorageFile.java b/src/seedu/addressbook/storage/StorageFile.java index 41147edf5..4c9f71c05 100644 --- a/src/seedu/addressbook/storage/StorageFile.java +++ b/src/seedu/addressbook/storage/StorageFile.java @@ -15,7 +15,9 @@ */ public class StorageFile { - /** Default file path used if the user doesn't provide the file name. */ + /** + * Default file path used if the user doesn't provide the file name. + */ public static final String DEFAULT_STORAGE_FILEPATH = "addressbook.txt"; /* Note: Note the use of nested classes below. @@ -98,7 +100,7 @@ public AddressBook load() throws StorageOperationException { return AddressBookDecoder.decodeAddressBook(Files.readAllLines(path)); } catch (FileNotFoundException fnfe) { throw new AssertionError("A non-existent file scenario is already handled earlier."); - // other errors + // other errors } catch (IOException ioe) { throw new StorageOperationException("Error writing to file: " + path); } catch (IllegalValueException ive) { diff --git a/test/expected.txt b/test/expected.txt index 56fe5fcac..c93940a1b 100644 --- a/test/expected.txt +++ b/test/expected.txt @@ -7,8 +7,8 @@ || =================================================== || Enter command: || [Command entered: sfdfd] || add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. -|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]... -|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || delete: Deletes the person identified by the index number used in the last person listing. || Parameters: INDEX || Example: delete 1 @@ -49,94 +49,112 @@ || Enter command: || [Command entered: add wrong args wrong args] || Invalid command format! || add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. -|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]... -|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: add Valid Name 12345 e/valid@email.butNoPhonePrefix a/valid, address] || Invalid command format! || add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. -|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]... -|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: add Valid Name p/12345 valid@email.butNoPrefix a/valid, address] || Invalid command format! || add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. -|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]... -|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: add Valid Name p/12345 e/valid@email.butNoAddressPrefix valid, address] || Invalid command format! || add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. -|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]... -|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: add Valid Name p/12345 e/valid@email.butNoTagPrefix a/valid, address t/goodTag noPrefixTag] -|| Tags names should be alphanumeric +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: add []\[;] p/12345 e/valid@e.mail a/valid, address] -|| Person names should be spaces or alphabetic characters +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: add Valid Name p/not_numbers e/valid@e.mail a/valid, address] -|| Person phone numbers should only contain numbers +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: add Valid Name p/12345 e/notAnEmail a/valid, address] -|| Person emails should be 2 alphanumeric/period strings separated by '@' +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: add Valid Name p/12345 e/valid@e.mail a/valid, address t/invalid_-[.tag] -|| Tags names should be alphanumeric +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: add Adam Brown p/111111 e/adam@gmail.com a/111, alpha street] -|| New person added: Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: list] -|| 1. Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: || -|| 1 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: add Betsy Choo pp/222222 pe/benchoo@nus.edu.sg pa/222, beta street t/secretive] -|| New person added: Betsy Choo Phone: (private) 222222 Email: (private) benchoo@nus.edu.sg Address: (private) 222, beta street Tags: [secretive] +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: list] -|| 1. Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: -|| 2. Betsy Choo Tags: [secretive] || -|| 2 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: add Charlie Dickson pp/333333 e/charlie.d@nus.edu.sg a/333, gamma street t/friends t/school] -|| New person added: Charlie Dickson Phone: (private) 333333 Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends] +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: list] -|| 1. Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: -|| 2. Betsy Choo Tags: [secretive] -|| 3. Charlie Dickson Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends] || -|| 3 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: add Dickson Ee p/444444 pe/dickson@nus.edu.sg a/444, delta street t/friends] -|| New person added: Dickson Ee Phone: 444444 Email: (private) dickson@nus.edu.sg Address: 444, delta street Tags: [friends] +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: list] -|| 1. Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: -|| 2. Betsy Choo Tags: [secretive] -|| 3. Charlie Dickson Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends] -|| 4. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] || -|| 4 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: add Esther Potato p/555555 e/esther@not.a.real.potato pa/555, epsilon street t/tubers t/starchy] -|| New person added: Esther Potato Phone: 555555 Email: esther@not.a.real.potato Address: (private) 555, epsilon street Tags: [tubers][starchy] +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: list] -|| 1. Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: -|| 2. Betsy Choo Tags: [secretive] -|| 3. Charlie Dickson Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends] -|| 4. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] -|| 5. Esther Potato Phone: 555555 Email: esther@not.a.real.potato Tags: [tubers][starchy] || -|| 5 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: add Esther Potato p/555555 e/esther@not.a.real.potato pa/555, epsilon street t/tubers t/starchy] -|| This person already exists in the address book +|| Invalid command format! +|| add: Adds a person to the address book. Contact details can be marked private by prepending 'p' to the prefix. +|| Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [p]m/MAJOR [t/TAG]... +|| Example: add John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 m/CS t/friends t/owesMoney || =================================================== || Enter command: || [Command entered: view] || Invalid command format! @@ -175,28 +193,28 @@ || The person index provided is invalid || =================================================== || Enter command: || [Command entered: view 1] -|| Viewing person: Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: viewall 1] -|| Viewing person: Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: view 3] -|| Viewing person: Charlie Dickson Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends] +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: view 4] -|| Viewing person: Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: view 5] -|| Viewing person: Esther Potato Phone: 555555 Email: esther@not.a.real.potato Tags: [tubers][starchy] +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: viewall 3] -|| Viewing person: Charlie Dickson Phone: (private) 333333 Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends] +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: viewall 4] -|| Viewing person: Dickson Ee Phone: 444444 Email: (private) dickson@nus.edu.sg Address: 444, delta street Tags: [friends] +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: viewall 5] -|| Viewing person: Esther Potato Phone: 555555 Email: esther@not.a.real.potato Address: (private) 555, epsilon street Tags: [tubers][starchy] +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: find] || Invalid command format! @@ -217,21 +235,16 @@ || 0 persons listed! || =================================================== || Enter command: || [Command entered: find Betsy] -|| 1. Betsy Choo Tags: [secretive] || -|| 1 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: find Dickson] -|| 1. Charlie Dickson Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends] -|| 2. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] || -|| 2 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: find Charlie Betsy] -|| 1. Betsy Choo Tags: [secretive] -|| 2. Charlie Dickson Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends] || -|| 2 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: delete] || Invalid command format! @@ -252,43 +265,34 @@ || The person index provided is invalid || =================================================== || Enter command: || [Command entered: delete 2] -|| Deleted Person: Charlie Dickson Phone: (private) 333333 Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends] +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: delete 2] -|| Person could not be found in address book +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: view 2] -|| Person could not be found in address book +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: viewall 2] -|| Person could not be found in address book +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: list] -|| 1. Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: -|| 2. Betsy Choo Tags: [secretive] -|| 3. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] -|| 4. Esther Potato Phone: 555555 Email: esther@not.a.real.potato Tags: [tubers][starchy] || -|| 4 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: delete 4] -|| Deleted Person: Esther Potato Phone: 555555 Email: esther@not.a.real.potato Address: (private) 555, epsilon street Tags: [tubers][starchy] +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: list] -|| 1. Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: -|| 2. Betsy Choo Tags: [secretive] -|| 3. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] || -|| 3 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: delete 1] -|| Deleted Person: Adam Brown Phone: 111111 Email: adam@gmail.com Address: 111, alpha street Tags: +|| The person index provided is invalid || =================================================== || Enter command: || [Command entered: list] -|| 1. Betsy Choo Tags: [secretive] -|| 2. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends] || -|| 2 persons listed! +|| 0 persons listed! || =================================================== || Enter command: || [Command entered: clear] || Address book has been cleared! diff --git a/test/java/seedu/addressbook/commands/AddCommandTest.java b/test/java/seedu/addressbook/commands/AddCommandTest.java index 461017710..0a65881ed 100644 --- a/test/java/seedu/addressbook/commands/AddCommandTest.java +++ b/test/java/seedu/addressbook/commands/AddCommandTest.java @@ -19,6 +19,7 @@ import seedu.addressbook.data.person.Email; import seedu.addressbook.data.person.Name; import seedu.addressbook.data.person.Person; +import seedu.addressbook.data.person.Major; import seedu.addressbook.data.person.Phone; import seedu.addressbook.data.person.ReadOnlyPerson; import seedu.addressbook.data.person.UniquePersonList; @@ -33,7 +34,7 @@ public void addCommand_invalidName_throwsException() { final String[] invalidNames = { "", " ", "[]\\[;]" }; for (String name : invalidNames) { assertConstructingInvalidAddCmdThrowsException(name, Phone.EXAMPLE, true, Email.EXAMPLE, false, - Address.EXAMPLE, true, EMPTY_STRING_SET); + Address.EXAMPLE, true, Major.EXAMPLE, false, EMPTY_STRING_SET); } } @@ -42,7 +43,7 @@ public void addCommand_invalidPhone_throwsException() { final String[] invalidNumbers = { "", " ", "1234-5678", "[]\\[;]", "abc", "a123", "+651234" }; for (String number : invalidNumbers) { assertConstructingInvalidAddCmdThrowsException(Name.EXAMPLE, number, false, Email.EXAMPLE, true, - Address.EXAMPLE, false, EMPTY_STRING_SET); + Address.EXAMPLE, false, Major.EXAMPLE, false, EMPTY_STRING_SET); } } @@ -52,7 +53,7 @@ public void addCommand_invalidEmail_throwsException() { "@invalid@email", "invalid@email!", "!invalid@email" }; for (String email : invalidEmails) { assertConstructingInvalidAddCmdThrowsException(Name.EXAMPLE, Phone.EXAMPLE, false, email, false, - Address.EXAMPLE, false, EMPTY_STRING_SET); + Address.EXAMPLE, false, Major.EXAMPLE, false, EMPTY_STRING_SET); } } @@ -61,7 +62,7 @@ public void addCommand_invalidAddress_throwsException() { final String[] invalidAddresses = { "", " " }; for (String address : invalidAddresses) { assertConstructingInvalidAddCmdThrowsException(Name.EXAMPLE, Phone.EXAMPLE, true, Email.EXAMPLE, - true, address, true, EMPTY_STRING_SET); + true, address, true, Major.EXAMPLE, false, EMPTY_STRING_SET); } } @@ -72,7 +73,7 @@ public void addCommand_invalidTags_throwsException() { for (String[] tags : invalidTags) { Set tagsToAdd = new HashSet<>(Arrays.asList(tags)); assertConstructingInvalidAddCmdThrowsException(Name.EXAMPLE, Phone.EXAMPLE, true, Email.EXAMPLE, - true, Address.EXAMPLE, false, tagsToAdd); + true, Address.EXAMPLE, false, Major.EXAMPLE, false,tagsToAdd); } } @@ -82,10 +83,10 @@ public void addCommand_invalidTags_throwsException() { */ private void assertConstructingInvalidAddCmdThrowsException(String name, String phone, boolean isPhonePrivate, String email, boolean isEmailPrivate, String address, - boolean isAddressPrivate, Set tags) { + boolean isAddressPrivate, String major, boolean isMajorPrivate,Set tags) { try { - new AddCommand(name, phone, isPhonePrivate, email, isEmailPrivate, address, isAddressPrivate, - tags); + new AddCommand(name, phone, isPhonePrivate, email, isEmailPrivate, address, isAddressPrivate,major, + isMajorPrivate, tags); } catch (IllegalValueException e) { return; } @@ -98,7 +99,7 @@ private void assertConstructingInvalidAddCmdThrowsException(String name, String @Test public void addCommand_validData_correctlyConstructed() throws Exception { AddCommand command = new AddCommand(Name.EXAMPLE, Phone.EXAMPLE, true, Email.EXAMPLE, false, - Address.EXAMPLE, true, EMPTY_STRING_SET); + Address.EXAMPLE, true, Major.EXAMPLE, false,EMPTY_STRING_SET); ReadOnlyPerson p = command.getPerson(); // TODO: add comparison of tags to person.equals and equality methods to diff --git a/test/java/seedu/addressbook/commands/DeleteCommandTest.java b/test/java/seedu/addressbook/commands/DeleteCommandTest.java index 02a77b0c2..22c589278 100644 --- a/test/java/seedu/addressbook/commands/DeleteCommandTest.java +++ b/test/java/seedu/addressbook/commands/DeleteCommandTest.java @@ -14,6 +14,7 @@ import seedu.addressbook.data.person.Address; import seedu.addressbook.data.person.Email; import seedu.addressbook.data.person.Name; +import seedu.addressbook.data.person.Major; import seedu.addressbook.data.person.Person; import seedu.addressbook.data.person.Phone; import seedu.addressbook.data.person.ReadOnlyPerson; @@ -33,14 +34,17 @@ public class DeleteCommandTest { @Before public void setUp() throws Exception { Person johnDoe = new Person(new Name("John Doe"), new Phone("61234567", false), - new Email("john@doe.com", false), new Address("395C Ben Road", false), Collections.emptySet()); + new Email("john@doe.com", false), new Address("395C Ben Road", false), + new Major("Computing", false), Collections.emptySet()); Person janeDoe = new Person(new Name("Jane Doe"), new Phone("91234567", false), - new Email("jane@doe.com", false), new Address("33G Ohm Road", false), Collections.emptySet()); + new Email("jane@doe.com", false), new Address("33G Ohm Road", false), + new Major("Computing", false), Collections.emptySet()); Person samDoe = new Person(new Name("Sam Doe"), new Phone("63345566", false), - new Email("sam@doe.com", false), new Address("55G Abc Road", false), Collections.emptySet()); + new Email("sam@doe.com", false), new Address("55G Abc Road", false), + new Major("Computing", false), Collections.emptySet()); Person davidGrant = new Person(new Name("David Grant"), new Phone("61121122", false), new Email("david@grant.com", false), new Address("44H Define Road", false), - Collections.emptySet()); + new Major("Computing", false), Collections.emptySet()); emptyAddressBook = TestUtil.createAddressBook(); addressBook = TestUtil.createAddressBook(johnDoe, janeDoe, davidGrant, samDoe); @@ -65,7 +69,7 @@ public void execute_noPersonDisplayed_returnsInvalidIndexMessage() { public void execute_targetPersonNotInAddressBook_returnsPersonNotFoundMessage() throws IllegalValueException { Person notInAddressBookPerson = new Person(new Name("Not In Book"), new Phone("63331444", false), - new Email("notin@book.com", false), new Address("156D Grant Road", false), Collections.emptySet()); + new Email("notin@book.com", false), new Address("156D Grant Road", false), new Major("Computing", false), Collections.emptySet()); List listWithPersonNotInAddressBook = TestUtil.createList(notInAddressBookPerson); assertDeletionFailsDueToNoSuchPerson(1, addressBook, listWithPersonNotInAddressBook); @@ -93,7 +97,7 @@ public void execute_validIndex_personIsDeleted() throws PersonNotFoundException * @param targetVisibleIndex of the person that we want to delete */ private DeleteCommand createDeleteCommand(int targetVisibleIndex, AddressBook addressBook, - List displayList) { + List displayList) { DeleteCommand command = new DeleteCommand(targetVisibleIndex); command.setData(addressBook, displayList); @@ -117,7 +121,7 @@ private void assertCommandBehaviour(DeleteCommand deleteCommand, String expected * Asserts that the index is not valid for the given display list. */ private void assertDeletionFailsDueToInvalidIndex(int invalidVisibleIndex, AddressBook addressBook, - List displayList) { + List displayList) { String expectedMessage = Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; @@ -130,7 +134,7 @@ private void assertDeletionFailsDueToInvalidIndex(int invalidVisibleIndex, Addre * is not in the address book. */ private void assertDeletionFailsDueToNoSuchPerson(int visibleIndex, AddressBook addressBook, - List displayList) { + List displayList) { String expectedMessage = Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK; @@ -140,7 +144,7 @@ private void assertDeletionFailsDueToNoSuchPerson(int visibleIndex, AddressBook /** * Asserts that the person at the specified index can be successfully deleted. - * + *

* The addressBook passed in will not be modified (no side effects). * * @throws PersonNotFoundException if the selected person is not in the address book diff --git a/test/java/seedu/addressbook/commands/ViewCommandTest.java b/test/java/seedu/addressbook/commands/ViewCommandTest.java index f2e4d420a..2de9a8c83 100644 --- a/test/java/seedu/addressbook/commands/ViewCommandTest.java +++ b/test/java/seedu/addressbook/commands/ViewCommandTest.java @@ -12,12 +12,7 @@ import seedu.addressbook.common.Messages; import seedu.addressbook.data.AddressBook; -import seedu.addressbook.data.person.Address; -import seedu.addressbook.data.person.Email; -import seedu.addressbook.data.person.Name; -import seedu.addressbook.data.person.Person; -import seedu.addressbook.data.person.Phone; -import seedu.addressbook.data.person.ReadOnlyPerson; +import seedu.addressbook.data.person.*; import seedu.addressbook.util.TestUtil; import seedu.addressbook.util.TypicalPersons; @@ -49,6 +44,7 @@ public void execute_personNotInAddressBook_returnsPersonNotInAddressBookMessage( new Phone("123", true), new Email("some@hey.go", true), new Address("nus", false), + new Major("Computing",false), Collections.emptySet()); List listWithExtraPerson = new ArrayList(listWithAllTypicalPersons); diff --git a/test/java/seedu/addressbook/data/AddressBookTest.java b/test/java/seedu/addressbook/data/AddressBookTest.java index 193229774..3357c12c0 100644 --- a/test/java/seedu/addressbook/data/AddressBookTest.java +++ b/test/java/seedu/addressbook/data/AddressBookTest.java @@ -18,6 +18,7 @@ import seedu.addressbook.data.person.Address; import seedu.addressbook.data.person.Email; import seedu.addressbook.data.person.Name; +import seedu.addressbook.data.person.Major; import seedu.addressbook.data.person.Person; import seedu.addressbook.data.person.Phone; import seedu.addressbook.data.person.UniquePersonList; @@ -42,34 +43,38 @@ public class AddressBookTest { @Before public void setUp() throws Exception { - tagPrizeWinner = new Tag("prizewinner"); - tagScientist = new Tag("scientist"); + tagPrizeWinner = new Tag("prizewinner"); + tagScientist = new Tag("scientist"); tagMathematician = new Tag("mathematician"); - tagEconomist = new Tag("economist"); - - aliceBetsy = new Person(new Name("Alice Betsy"), - new Phone("91235468", false), - new Email("alice@nushackers.org", false), - new Address("8 Computing Drive, Singapore", false), - Collections.singleton(tagMathematician)); - - bobChaplin = new Person(new Name("Bob Chaplin"), - new Phone("94321500", false), - new Email("bob@nusgreyhats.org", false), - new Address("9 Computing Drive", false), - Collections.singleton(tagMathematician)); + tagEconomist = new Tag("economist"); + + aliceBetsy = new Person(new Name("Alice Betsy"), + new Phone("91235468", false), + new Email("alice@nushackers.org", false), + new Address("8 Computing Drive, Singapore", false), + new Major("Computing", false), + Collections.singleton(tagMathematician)); + + bobChaplin = new Person(new Name("Bob Chaplin"), + new Phone("94321500", false), + new Email("bob@nusgreyhats.org", false), + new Address("9 Computing Drive", false), + new Major("Computing", false), + Collections.singleton(tagMathematician)); charlieDouglas = new Person(new Name("Charlie Douglas"), - new Phone("98751365", false), - new Email("charlie@nusgdg.org", false), - new Address("10 Science Drive", false), - Collections.singleton(tagScientist)); - - davidElliot = new Person(new Name("David Elliot"), - new Phone("84512575", false), - new Email("douglas@nuscomputing.com", false), - new Address("11 Arts Link", false), - new HashSet<>(Arrays.asList(tagEconomist, tagPrizeWinner))); + new Phone("98751365", false), + new Email("charlie@nusgdg.org", false), + new Address("10 Science Drive", false), + new Major("Computing", false), + Collections.singleton(tagScientist)); + + davidElliot = new Person(new Name("David Elliot"), + new Phone("84512575", false), + new Email("douglas@nuscomputing.com", false), + new Address("11 Arts Link", false), + new Major("Computing", false), + new HashSet<>(Arrays.asList(tagEconomist, tagPrizeWinner))); emptyAddressBook = new AddressBook(); defaultAddressBook = new AddressBook(new UniquePersonList(aliceBetsy, bobChaplin)); diff --git a/test/java/seedu/addressbook/parser/ParserTest.java b/test/java/seedu/addressbook/parser/ParserTest.java index 0dfc67cd2..ad25a6c53 100644 --- a/test/java/seedu/addressbook/parser/ParserTest.java +++ b/test/java/seedu/addressbook/parser/ParserTest.java @@ -28,6 +28,7 @@ import seedu.addressbook.data.person.Email; import seedu.addressbook.data.person.Name; import seedu.addressbook.data.person.Person; +import seedu.addressbook.data.person.Major; import seedu.addressbook.data.person.Phone; import seedu.addressbook.data.person.ReadOnlyPerson; import seedu.addressbook.data.tag.Tag; @@ -275,6 +276,7 @@ private static Person generateTestPerson() { new Phone(Phone.EXAMPLE, true), new Email(Email.EXAMPLE, false), new Address(Address.EXAMPLE, true), + new Major(Major.EXAMPLE, false), new HashSet<>(Arrays.asList(new Tag("tag1"), new Tag ("tag2"), new Tag("tag3"))) ); } catch (IllegalValueException ive) { @@ -287,7 +289,8 @@ private static String convertPersonToAddCommandString(ReadOnlyPerson person) { + person.getName().fullName + (person.getPhone().isPrivate() ? " pp/" : " p/") + person.getPhone().value + (person.getEmail().isPrivate() ? " pe/" : " e/") + person.getEmail().value - + (person.getAddress().isPrivate() ? " pa/" : " a/") + person.getAddress().value; + + (person.getAddress().isPrivate() ? " pa/" : " a/") + person.getAddress().value + + (person.getMajor().isPrivate() ? " pm/" : " m/") + person.getMajor().value; for (Tag tag : person.getTags()) { addCommand += " t/" + tag.tagName; } diff --git a/test/java/seedu/addressbook/storage/StorageFileTest.java b/test/java/seedu/addressbook/storage/StorageFileTest.java index f2c907296..e05ee9271 100644 --- a/test/java/seedu/addressbook/storage/StorageFileTest.java +++ b/test/java/seedu/addressbook/storage/StorageFileTest.java @@ -14,13 +14,10 @@ import seedu.addressbook.data.AddressBook; import seedu.addressbook.data.exception.IllegalValueException; -import seedu.addressbook.data.person.Address; -import seedu.addressbook.data.person.Email; -import seedu.addressbook.data.person.Name; -import seedu.addressbook.data.person.Person; -import seedu.addressbook.data.person.Phone; +import seedu.addressbook.data.person.*; import seedu.addressbook.data.tag.Tag; import seedu.addressbook.storage.StorageFile.StorageOperationException; + import static seedu.addressbook.util.TestUtil.assertTextFilesEqual; import static seedu.addressbook.util.TestUtil.assertFileDoesNotExist; @@ -111,15 +108,17 @@ private StorageFile getTempStorage() throws Exception { private AddressBook getTestAddressBook() throws Exception { AddressBook ab = new AddressBook(); ab.addPerson(new Person(new Name("John Doe"), - new Phone("98765432", false), - new Email("johnd@gmail.com", false), - new Address("John street, block 123, #01-01", false), - Collections.emptySet())); + new Phone("98765432", false), + new Email("johnd@gmail.com", false), + new Address("John street, block 123, #01-01", false), + new Major("Computing", false), + Collections.emptySet())); ab.addPerson(new Person(new Name("Betsy Crowe"), - new Phone("1234567", true), - new Email("betsycrowe@gmail.com", false), - new Address("Newgate Prison", true), - new HashSet<>(Arrays.asList(new Tag("friend"), new Tag("criminal"))))); + new Phone("1234567", true), + new Email("betsycrowe@gmail.com", false), + new Address("Newgate Prison", true), + new Major("Computing", false), + new HashSet<>(Arrays.asList(new Tag("friend"), new Tag("criminal"))))); return ab; } } diff --git a/test/java/seedu/addressbook/util/TestUtil.java b/test/java/seedu/addressbook/util/TestUtil.java index b286bb4bd..5325929b1 100644 --- a/test/java/seedu/addressbook/util/TestUtil.java +++ b/test/java/seedu/addressbook/util/TestUtil.java @@ -16,12 +16,7 @@ import seedu.addressbook.data.AddressBook; import seedu.addressbook.data.exception.IllegalValueException; -import seedu.addressbook.data.person.Address; -import seedu.addressbook.data.person.Email; -import seedu.addressbook.data.person.Name; -import seedu.addressbook.data.person.Person; -import seedu.addressbook.data.person.Phone; -import seedu.addressbook.data.person.ReadOnlyPerson; +import seedu.addressbook.data.person.*; import seedu.addressbook.data.person.UniquePersonList.DuplicatePersonException; public class TestUtil { @@ -45,7 +40,7 @@ public static AddressBook createAddressBook(Person... persons) { /** * Creates a list of persons. */ - public static List createList(Person...persons) { + public static List createList(Person... persons) { List list = new ArrayList(); for (Person person : persons) { @@ -107,7 +102,8 @@ public static int getSize(Iterable it) { public static Person generateTestPerson() { try { return new Person(new Name(Name.EXAMPLE), new Phone(Phone.EXAMPLE, false), - new Email(Email.EXAMPLE, true), new Address(Address.EXAMPLE, false), Collections.emptySet()); + new Email(Email.EXAMPLE, true), new Address(Address.EXAMPLE, false), + new Major("Computing", false), Collections.emptySet()); } catch (IllegalValueException e) { fail("test person data should be valid by definition"); return null; diff --git a/test/java/seedu/addressbook/util/TypicalPersons.java b/test/java/seedu/addressbook/util/TypicalPersons.java index cd3a3f819..1da94ad5a 100644 --- a/test/java/seedu/addressbook/util/TypicalPersons.java +++ b/test/java/seedu/addressbook/util/TypicalPersons.java @@ -4,11 +4,7 @@ import seedu.addressbook.data.AddressBook; import seedu.addressbook.data.exception.IllegalValueException; -import seedu.addressbook.data.person.Address; -import seedu.addressbook.data.person.Email; -import seedu.addressbook.data.person.Name; -import seedu.addressbook.data.person.Person; -import seedu.addressbook.data.person.Phone; +import seedu.addressbook.data.person.*; import seedu.addressbook.data.tag.Tag; /** @@ -21,13 +17,13 @@ public class TypicalPersons { public TypicalPersons() { try { amy = new Person(new Name("Amy Buck"), new Phone("91119111", false), new Email("ab@gmail.com", false), - new Address("1 Clementi Road", false), Collections.emptySet()); + new Address("1 Clementi Road", false), new Major("Computing",false), Collections.emptySet()); bill = new Person(new Name("Bill Clint"), new Phone("92229222", false), new Email("bc@gmail.com", false), - new Address("2 Clementi Road", true), Collections.emptySet()); + new Address("2 Clementi Road", true), new Major("Computing",false), Collections.emptySet()); candy = new Person(new Name("Candy Destiny"), new Phone("93339333", true), - new Email("cd@gmail.com", false), new Address("3 Clementi Road", true), Collections.emptySet()); + new Email("cd@gmail.com", false), new Address("3 Clementi Road", true), new Major("Computing",false), Collections.emptySet()); dan = new Person(new Name("Dan Smith"), new Phone("1234556", true), new Email("ss@tt.com", true), - new Address("NUS", true), Collections.singleton(new Tag("test"))); + new Address("NUS", true), new Major("Computing",false), Collections.singleton(new Tag("test"))); } catch (IllegalValueException e) { e.printStackTrace(); assert false : "not possible";