From eb1cba80fd4496366121dd12ba9e2d83d511e61e Mon Sep 17 00:00:00 2001 From: hypertun Date: Thu, 8 Mar 2018 16:36:31 +0800 Subject: [PATCH 001/227] Updated the glossary in the Developer Guide --- docs/DeveloperGuide.adoc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 1733af113b29..5fe045f283b4 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -864,6 +864,33 @@ Windows, Linux, Unix, OS-X [[private-contact-detail]] Private contact detail:: A contact detail that is not meant to be shared with others +[[personal-trainer]] Personal trainer:: +Target audience + +[[trainer]] Trainer:: +Same as above + +[[client]] Client:: +Indirect target audience, due the the fact the employer-employee relationship between them and trainers + +[[track]] Track:: +Understanding the fitness(e.g. weight loss/gain, calories, protein) progress of the clients + +[[meal-plans]] Meal plan:: +A combination of dietary information that should be followed + +[[training]] Training:: +A period of time when client is working out + +[[session]] Session:: +Same as above + +[[appointment]] Appointment:: +Same as above + +[[goals]] Goals:: +A combination of desirable attributes that clients want to achieve + [appendix] == Product Survey From a8d11df97c56f934abaf1997306e917bcff00353 Mon Sep 17 00:00:00 2001 From: hypertun Date: Thu, 8 Mar 2018 17:35:46 +0800 Subject: [PATCH 002/227] Updated the readme.adoc --- README.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.adoc b/README.adoc index 03eff3a4d191..86de8ab30268 100644 --- a/README.adoc +++ b/README.adoc @@ -1,9 +1,9 @@ = Address Book (Level 4) ifdef::env-github,env-browser[:relfileprefix: docs/] -https://travis-ci.org/se-edu/addressbook-level4[image:https://travis-ci.org/se-edu/addressbook-level4.svg?branch=master[Build Status]] -https://ci.appveyor.com/project/damithc/addressbook-level4[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] -https://coveralls.io/github/se-edu/addressbook-level4?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level4/badge.svg?branch=master[Coverage Status]] +https://travis-ci.org/CS2103JAN2018-F12-B2/main[image:https://travis-ci.org/CS2103JAN2018-F12-B2/main.svg?branch=master[Build Status]] +https://ci.appveyor.com/project/hypertun/main/branch/master[image:https://ci.appveyor.com/api/projects/status/690sw2r4l3lxa1fr/branch/master?svg=true[Build status]] +https://coveralls.io/github/CS2103JAN2018-F12-B2/main?branch=master[image:https://coveralls.io/repos/github/CS2103JAN2018-F12-B2/main/badge.svg?branch=master[Coverage Status]] https://www.codacy.com/app/damith/addressbook-level4?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level4&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]] https://gitter.im/se-edu/Lobby[image:https://badges.gitter.im/se-edu/Lobby.svg[Gitter chat]] From 7e6c447b836b497841300843d424fb01810605c0 Mon Sep 17 00:00:00 2001 From: hypertun Date: Thu, 8 Mar 2018 17:44:36 +0800 Subject: [PATCH 003/227] Updated the developerguide for the team repo --- docs/DeveloperGuide.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 5fe045f283b4..ae4aec5c8619 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -10,7 +10,7 @@ ifdef::env-github[] :tip-caption: :bulb: :note-caption: :information_source: endif::[] -:repoURL: https://github.com/se-edu/addressbook-level4/tree/master +:repoURL: https://github.com/CS2103JAN2018-F12-B2/main/tree/master By: `Team SE-EDU`      Since: `Jun 2016`      Licence: `MIT` From 9383c81e731f0a0954b839b4664ed93c35bc1fe6 Mon Sep 17 00:00:00 2001 From: hypertun Date: Thu, 8 Mar 2018 23:24:51 +0800 Subject: [PATCH 004/227] Added command Alias v1.0 --- .../address/logic/commands/AddCommand.java | 1 + .../address/logic/commands/ClearCommand.java | 1 + .../address/logic/commands/DeleteCommand.java | 1 + .../address/logic/commands/EditCommand.java | 1 + .../address/logic/commands/FindCommand.java | 1 + .../address/logic/commands/ListCommand.java | 1 + .../address/logic/commands/SelectCommand.java | 1 + .../logic/parser/AddressBookParser.java | 7 +++ .../logic/parser/AddressBookParserTest.java | 51 +++++++++++++++++++ 9 files changed, 65 insertions(+) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index c334710c0ea3..d5de4a572715 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -17,6 +17,7 @@ public class AddCommand extends UndoableCommand { public static final String COMMAND_WORD = "add"; + public static final String COMMAND_ALIAS = "a"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " + "Parameters: " diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index ceeb7ba913c6..6d04efaf3295 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -10,6 +10,7 @@ public class ClearCommand extends UndoableCommand { public static final String COMMAND_WORD = "clear"; + public static final String COMMAND_ALIAS = "c"; public static final String MESSAGE_SUCCESS = "Address book has been cleared!"; diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index b539d240001a..0cd0fbd860ad 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -17,6 +17,7 @@ public class DeleteCommand extends UndoableCommand { public static final String COMMAND_WORD = "delete"; + public static final String COMMAND_ALIAS = "d"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Deletes the person identified by the index number used in the last person listing.\n" diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index e6c3a3e034bc..3021c951a5b1 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -34,6 +34,7 @@ public class EditCommand extends UndoableCommand { public static final String COMMAND_WORD = "edit"; + public static final String COMMAND_ALIAS = "e"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified " + "by the index number used in the last person listing. " diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index b1e671f633d2..a73078ed6ea3 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -9,6 +9,7 @@ public class FindCommand extends Command { public static final String COMMAND_WORD = "find"; + public static final String COMMAND_ALIAS = "f"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " + "the specified keywords (case-sensitive) and displays them as a list with index numbers.\n" diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 7b6463780824..2631e4dda649 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -8,6 +8,7 @@ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; + public static final String COMMAND_ALIAS = "l"; public static final String MESSAGE_SUCCESS = "Listed all persons"; diff --git a/src/main/java/seedu/address/logic/commands/SelectCommand.java b/src/main/java/seedu/address/logic/commands/SelectCommand.java index 9e3840a9dde6..0bc2e3e21485 100644 --- a/src/main/java/seedu/address/logic/commands/SelectCommand.java +++ b/src/main/java/seedu/address/logic/commands/SelectCommand.java @@ -15,6 +15,7 @@ public class SelectCommand extends Command { public static final String COMMAND_WORD = "select"; + public static final String COMMAND_ALIAS = "s"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Selects the person identified by the index number used in the last person listing.\n" diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index b7d57f5db86a..0716002b8ead 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -49,24 +49,31 @@ public Command parseCommand(String userInput) throws ParseException { switch (commandWord) { case AddCommand.COMMAND_WORD: + case AddCommand.COMMAND_ALIAS: return new AddCommandParser().parse(arguments); case EditCommand.COMMAND_WORD: + case EditCommand.COMMAND_ALIAS: return new EditCommandParser().parse(arguments); case SelectCommand.COMMAND_WORD: + case SelectCommand.COMMAND_ALIAS: return new SelectCommandParser().parse(arguments); case DeleteCommand.COMMAND_WORD: + case DeleteCommand.COMMAND_ALIAS: return new DeleteCommandParser().parse(arguments); case ClearCommand.COMMAND_WORD: + case ClearCommand.COMMAND_ALIAS: return new ClearCommand(); case FindCommand.COMMAND_WORD: + case FindCommand.COMMAND_ALIAS: return new FindCommandParser().parse(arguments); case ListCommand.COMMAND_WORD: + case ListCommand.COMMAND_ALIAS: return new ListCommand(); case HistoryCommand.COMMAND_WORD: diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 7466da232666..3c20f2369f6e 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -48,12 +48,26 @@ public void parseCommand_add() throws Exception { assertEquals(new AddCommand(person), command); } + @Test + public void parseCommand_addAlias() throws Exception { + Person person = new PersonBuilder().build(); + AddCommand command = (AddCommand) parser.parseCommand(AddCommand.COMMAND_ALIAS + " " + + PersonUtil.getPersonDetails(person)); + assertEquals(new AddCommand(person), command); + } + @Test public void parseCommand_clear() throws Exception { assertTrue(parser.parseCommand(ClearCommand.COMMAND_WORD) instanceof ClearCommand); assertTrue(parser.parseCommand(ClearCommand.COMMAND_WORD + " 3") instanceof ClearCommand); } + @Test + public void parseCommand_clearAlias() throws Exception { + assertTrue(parser.parseCommand(ClearCommand.COMMAND_ALIAS) instanceof ClearCommand); + assertTrue(parser.parseCommand(ClearCommand.COMMAND_ALIAS + " 3") instanceof ClearCommand); + } + @Test public void parseCommand_delete() throws Exception { DeleteCommand command = (DeleteCommand) parser.parseCommand( @@ -61,6 +75,13 @@ public void parseCommand_delete() throws Exception { assertEquals(new DeleteCommand(INDEX_FIRST_PERSON), command); } + @Test + public void parseCommand_deleteAlias() throws Exception { + DeleteCommand command = (DeleteCommand) parser.parseCommand( + DeleteCommand.COMMAND_ALIAS + " " + INDEX_FIRST_PERSON.getOneBased()); + assertEquals(new DeleteCommand(INDEX_FIRST_PERSON), command); + } + @Test public void parseCommand_edit() throws Exception { Person person = new PersonBuilder().build(); @@ -70,6 +91,15 @@ public void parseCommand_edit() throws Exception { assertEquals(new EditCommand(INDEX_FIRST_PERSON, descriptor), command); } + @Test + public void parseCommand_editAlias() throws Exception { + Person person = new PersonBuilder().build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person).build(); + EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_ALIAS + " " + + INDEX_FIRST_PERSON.getOneBased() + " " + PersonUtil.getPersonDetails(person)); + assertEquals(new EditCommand(INDEX_FIRST_PERSON, descriptor), command); + } + @Test public void parseCommand_exit() throws Exception { assertTrue(parser.parseCommand(ExitCommand.COMMAND_WORD) instanceof ExitCommand); @@ -84,6 +114,14 @@ public void parseCommand_find() throws Exception { assertEquals(new FindCommand(new NameContainsKeywordsPredicate(keywords)), command); } + @Test + public void parseCommand_findAlias() throws Exception { + List keywords = Arrays.asList("foo", "bar", "baz"); + FindCommand command = (FindCommand) parser.parseCommand( + FindCommand.COMMAND_ALIAS + " " + keywords.stream().collect(Collectors.joining(" "))); + assertEquals(new FindCommand(new NameContainsKeywordsPredicate(keywords)), command); + } + @Test public void parseCommand_help() throws Exception { assertTrue(parser.parseCommand(HelpCommand.COMMAND_WORD) instanceof HelpCommand); @@ -109,6 +147,12 @@ public void parseCommand_list() throws Exception { assertTrue(parser.parseCommand(ListCommand.COMMAND_WORD + " 3") instanceof ListCommand); } + @Test + public void parseCommand_listAlias() throws Exception { + assertTrue(parser.parseCommand(ListCommand.COMMAND_ALIAS) instanceof ListCommand); + assertTrue(parser.parseCommand(ListCommand.COMMAND_ALIAS + " 3") instanceof ListCommand); + } + @Test public void parseCommand_select() throws Exception { SelectCommand command = (SelectCommand) parser.parseCommand( @@ -116,6 +160,13 @@ public void parseCommand_select() throws Exception { assertEquals(new SelectCommand(INDEX_FIRST_PERSON), command); } + @Test + public void parseCommand_selectAlias() throws Exception { + SelectCommand command = (SelectCommand) parser.parseCommand( + SelectCommand.COMMAND_ALIAS + " " + INDEX_FIRST_PERSON.getOneBased()); + assertEquals(new SelectCommand(INDEX_FIRST_PERSON), command); + } + @Test public void parseCommand_redoCommandWord_returnsRedoCommand() throws Exception { assertTrue(parser.parseCommand(RedoCommand.COMMAND_WORD) instanceof RedoCommand); From 9626b69c60fb7bcd14f370b832ac19f25bdb79c2 Mon Sep 17 00:00:00 2001 From: praneeth Date: Fri, 9 Mar 2018 05:47:53 +0800 Subject: [PATCH 005/227] updates user guide, user profile, value proposistion --- docs/DeveloperGuide.adoc | 52 +++++++++++++++++++++++- src/main/java/seedu/address/MainApp.java | 2 +- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 1733af113b29..d9cdfa4d0f35 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -787,12 +787,62 @@ See this https://github.com/se-edu/addressbook-level4/pull/599[PR] for the step- * can type fast * prefers typing over mouse input * is reasonably comfortable using CLI apps +* people who keep records of other people +* people who want to track progress of other people (how they have changed) +* Personal Trainer *Value proposition*: manage contacts faster than a typical mouse/GUI driven app - +*Value proposition*: Lets PT keep track of their clients weight change per sessions +*Value proposition*: On command shows a graph of the trainee's weight loss +*Value proposition*: Allows the personal trainer to set goals for their +client and checks to see if they reached the goals +*Value proposition*: groups clients into subgroups (Obese, Underweight,..) +*Value proposition*: provide feedbacks on clients progress +*Value proposition*: keep a list of clients and expand clientele +*Value proposition*: [appendix] == User Stories +As a Personal Trainer, I can track the weight loss of my clients per session, so that I can track my clients progression. + + +As a Personal Trainer, I can look up specific training plans made by other trainers, so my clients have the best possible fitness regimen for their problem +As a Person Trainer, I can get reviews from my clients on what worked best for them and what didn’t, so that my training is improved +As a Personal Trainer, I can help clients who can’t make it to the session work though at-home workouts, so that clients are always exercising. +As a Personal Trainer, I can list mobility and strength imbalance issues my client has, allowing me to track his progress for his weak areas +As a Personal Trainer, I can see my clients day-to-day exercise schedule, so that i can keep a record of the exercise they pursue outside of sessions. +As a Personal Trainer, I can set list workouts with time’s associated, so that during workout i can keep track of how much time on a workout. +As a Personal Trainer, I can track which workouts my clients excel and lack, so that i can create a even more personalized workout experience. + + +As a Trainer, I can made a list of specific workouts tailored to each client, so that they can have a personalised coaching experience. +As a Trainer, I can make a list of meal plans for each specific day for my clients, so that they will be on track in their fitness journey. +(WH) Nice-To-Have As a Trainer, I can provide comments or feedbacks on my client’s progress, so that they will be motivated to carry on training. +As a Trainer, I can set goals for my clients, so that they will know what to work towards. +(WH) Must-Have As a Trainer, I can group my clients into subgroups (e.g. Obese, Underweight), so that I can have an overview of my clients. (yes!!! But how can we implement this? Additional field, or special tags?) +As a client, I can view the comments my Trainer has provided for me, so that I can work on my weaker areas. +(WH) Nice-To-Have As a client, I can update my weight into the system, so that the Trainer can keep track of my progress. +As a client, I can key in any queries I might have into the system, so that I can receive clarification from my Trainer. +As a client, I can update my goals and activity, so that I can receive feedback and tips from my personal trainer; +As a client, I can see when my personal trainer is free, so that I can schedule extra sessions with him if needed. +(WH) Nice-To-Have As a client, I can cancel my sessions with my personal trainer when there is a schedule clash, so that I can inform my personal trainer beforehand. +As a client, I can check the location where my sessions are held at, so that I can plan my day ahead and make a smoother journey. +(WH) Must-Have As a Personal Trainer, I can add new clients and their data to my list, so that I can expand my career and extend my clientele. +As a Personal Trainer, I can set a cut-off timings for training sessions, so that I can have some personal time to do what I want apart from work. +As a Personal Trainer, I can amend my appointments and let my clients know of the change, so that I can better resolve potential clashes in appointments. +As a Personal Trainer, I can see how long each client has been with me, so that I can form better relationships with my clients by introducing incentives. + +As a client, I am able to check my weight loss, so that i know i am getting fitter. +As a client, i am able to help find other people of the same workout and timing, so that i can share my experiences. +As a client, i am able to check the remaining cost of the trainings that i have yet to pay, so that i will not have to constantly keep track. +As a Personal Trainer, I can allow my clients to track their progress but prevent them from accessing other clients information, to allow for privacy. +As a Personal Trainer, I can add various statistics(e.g. Weight, height, age, gender, calories,etc) to each client so that i can easily track and find them. +As a Personal Trainer, I can use the (APP?) to find out which aspect of each client can be improved, so that i can help them improve in fitness. +As a Personal Trainer, i can be alerted if i have a training session with a client in the near future, so that i will not upset clients. +(WH) Must-Have As a Personal Trainer, i can set a goal for the client and obtain the appropriate amount of calories and protein in order to reach the desired goal, so as to assist in grooming the client. + + + Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (unlikely to have) - `*` [width="59%",cols="22%,<23%,<25%,<30%",options="header",] diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index fa0800d55cb9..ed6ba8f79ab8 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -38,7 +38,7 @@ /** * The main entry point to the application. */ -public class MainApp extends Application { +public class hellMainApp extends Application { public static final Version VERSION = new Version(0, 6, 0, true); From a1166f4dfd67adc8c8219570e67af7ee1e5a16a3 Mon Sep 17 00:00:00 2001 From: wayneong95 Date: Fri, 9 Mar 2018 09:11:56 +0800 Subject: [PATCH 006/227] Updated non-functional requirements --- docs/DeveloperGuide.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 1733af113b29..142a22dfa76e 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -852,6 +852,9 @@ _{More to be added}_ . Should work on any <> as long as it has Java `1.8.0_60` or higher installed. . Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage. . A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse. +. Should be able to display data in a simple and clean format so a user is able to view the data with ease. +. New information submitted by user should be updated immediately. +. Client details should only be accessible to the client and the Trainer. _{More to be added}_ From e9ff443bcece14a2e19ccee9248924452ca5bb0b Mon Sep 17 00:00:00 2001 From: Wenhao Cheng Date: Fri, 9 Mar 2018 12:27:14 +0800 Subject: [PATCH 007/227] Update use cases in Developer Guide --- docs/DeveloperGuide.adoc | 54 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 1733af113b29..8756c7084552 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -844,7 +844,59 @@ Use case ends. + Use case resumes at step 2. -_{More to be added}_ + +=== Use case: Add person + +*MSS* + +1. User requests to add person +2. AddressBook prompts for data input +3. User inputs data for person to be added +4. AddressBook adds the new person ++ +Use case ends. + +*Extensions* + +[none] +* 3a. Person of the same name is already in AddressBook ++ +[none] +** 3a1. AddressBook shows an error message. ++ +Use case resumes at step 2. + +=== Use case: Add goal for person + +*MSS* + +1. User requests to add goal +2. AddressBook prompts for data input +3. User inputs person name and goal to be added +4. AddressBook adds the new goal for the person ++ +Use case ends. + +*Extensions* + +[none] +* 3a. The given index is invalid. ++ +[none] +** 3a1. AddressBook shows an error message. ++ +Use case resumes at step 2. + +[none] +* 3b. The given goal is empty. ++ +[none] +** 3b1. AddressBook shows an error message. ++ +Use case resumes at step 2. + + + [appendix] == Non Functional Requirements From b839ccaca529844ce84152596f1c2c627462ebbc Mon Sep 17 00:00:00 2001 From: wayneong95 Date: Fri, 9 Mar 2018 12:55:38 +0800 Subject: [PATCH 008/227] V1.0 Minor Enhancement - Implemented backup API for addressbook storage --- src/main/java/seedu/address/storage/AddressBookStorage.java | 1 + src/main/java/seedu/address/storage/StorageManager.java | 4 ++++ .../java/seedu/address/storage/XmlAddressBookStorage.java | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/src/main/java/seedu/address/storage/AddressBookStorage.java b/src/main/java/seedu/address/storage/AddressBookStorage.java index cf5b527c063a..08cdbbe6b0e2 100644 --- a/src/main/java/seedu/address/storage/AddressBookStorage.java +++ b/src/main/java/seedu/address/storage/AddressBookStorage.java @@ -41,4 +41,5 @@ public interface AddressBookStorage { */ void saveAddressBook(ReadOnlyAddressBook addressBook, String filePath) throws IOException; + void backupAddressBook(ReadOnlyAddressBook addressBook) throws IOException; } diff --git a/src/main/java/seedu/address/storage/StorageManager.java b/src/main/java/seedu/address/storage/StorageManager.java index 53967b391a5a..7a17725b0433 100644 --- a/src/main/java/seedu/address/storage/StorageManager.java +++ b/src/main/java/seedu/address/storage/StorageManager.java @@ -77,6 +77,10 @@ public void saveAddressBook(ReadOnlyAddressBook addressBook, String filePath) th addressBookStorage.saveAddressBook(addressBook, filePath); } + @Override + public void backupAddressBook(ReadOnlyAddressBook addressBook) throws IOException { + addressBookStorage.backupAddressBook(addressBook); + } @Override @Subscribe diff --git a/src/main/java/seedu/address/storage/XmlAddressBookStorage.java b/src/main/java/seedu/address/storage/XmlAddressBookStorage.java index c77ebe67435c..2d3a88f63ab9 100644 --- a/src/main/java/seedu/address/storage/XmlAddressBookStorage.java +++ b/src/main/java/seedu/address/storage/XmlAddressBookStorage.java @@ -61,6 +61,11 @@ public Optional readAddressBook(String filePath) throws Dat } } + @Override + public void backupAddressBook(ReadOnlyAddressBook addressBook) throws IOException { + saveAddressBook(addressBook, filePath + ".backup"); + } + @Override public void saveAddressBook(ReadOnlyAddressBook addressBook) throws IOException { saveAddressBook(addressBook, filePath); From 681b1168b595fcae9b3daa449fe9da46734a78c5 Mon Sep 17 00:00:00 2001 From: Yeo Chong Han Ivan <35591477+hypertun@users.noreply.github.com> Date: Fri, 9 Mar 2018 13:59:48 +0800 Subject: [PATCH 009/227] Revert "updates user guide, user profile, value proposistion" --- docs/DeveloperGuide.adoc | 52 +----------------------- src/main/java/seedu/address/MainApp.java | 2 +- 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 5ca56cfe7330..ae4aec5c8619 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -787,62 +787,12 @@ See this https://github.com/se-edu/addressbook-level4/pull/599[PR] for the step- * can type fast * prefers typing over mouse input * is reasonably comfortable using CLI apps -* people who keep records of other people -* people who want to track progress of other people (how they have changed) -* Personal Trainer *Value proposition*: manage contacts faster than a typical mouse/GUI driven app -*Value proposition*: Lets PT keep track of their clients weight change per sessions -*Value proposition*: On command shows a graph of the trainee's weight loss -*Value proposition*: Allows the personal trainer to set goals for their -client and checks to see if they reached the goals -*Value proposition*: groups clients into subgroups (Obese, Underweight,..) -*Value proposition*: provide feedbacks on clients progress -*Value proposition*: keep a list of clients and expand clientele -*Value proposition*: + [appendix] == User Stories -As a Personal Trainer, I can track the weight loss of my clients per session, so that I can track my clients progression. - - -As a Personal Trainer, I can look up specific training plans made by other trainers, so my clients have the best possible fitness regimen for their problem -As a Person Trainer, I can get reviews from my clients on what worked best for them and what didn’t, so that my training is improved -As a Personal Trainer, I can help clients who can’t make it to the session work though at-home workouts, so that clients are always exercising. -As a Personal Trainer, I can list mobility and strength imbalance issues my client has, allowing me to track his progress for his weak areas -As a Personal Trainer, I can see my clients day-to-day exercise schedule, so that i can keep a record of the exercise they pursue outside of sessions. -As a Personal Trainer, I can set list workouts with time’s associated, so that during workout i can keep track of how much time on a workout. -As a Personal Trainer, I can track which workouts my clients excel and lack, so that i can create a even more personalized workout experience. - - -As a Trainer, I can made a list of specific workouts tailored to each client, so that they can have a personalised coaching experience. -As a Trainer, I can make a list of meal plans for each specific day for my clients, so that they will be on track in their fitness journey. -(WH) Nice-To-Have As a Trainer, I can provide comments or feedbacks on my client’s progress, so that they will be motivated to carry on training. -As a Trainer, I can set goals for my clients, so that they will know what to work towards. -(WH) Must-Have As a Trainer, I can group my clients into subgroups (e.g. Obese, Underweight), so that I can have an overview of my clients. (yes!!! But how can we implement this? Additional field, or special tags?) -As a client, I can view the comments my Trainer has provided for me, so that I can work on my weaker areas. -(WH) Nice-To-Have As a client, I can update my weight into the system, so that the Trainer can keep track of my progress. -As a client, I can key in any queries I might have into the system, so that I can receive clarification from my Trainer. -As a client, I can update my goals and activity, so that I can receive feedback and tips from my personal trainer; -As a client, I can see when my personal trainer is free, so that I can schedule extra sessions with him if needed. -(WH) Nice-To-Have As a client, I can cancel my sessions with my personal trainer when there is a schedule clash, so that I can inform my personal trainer beforehand. -As a client, I can check the location where my sessions are held at, so that I can plan my day ahead and make a smoother journey. -(WH) Must-Have As a Personal Trainer, I can add new clients and their data to my list, so that I can expand my career and extend my clientele. -As a Personal Trainer, I can set a cut-off timings for training sessions, so that I can have some personal time to do what I want apart from work. -As a Personal Trainer, I can amend my appointments and let my clients know of the change, so that I can better resolve potential clashes in appointments. -As a Personal Trainer, I can see how long each client has been with me, so that I can form better relationships with my clients by introducing incentives. - -As a client, I am able to check my weight loss, so that i know i am getting fitter. -As a client, i am able to help find other people of the same workout and timing, so that i can share my experiences. -As a client, i am able to check the remaining cost of the trainings that i have yet to pay, so that i will not have to constantly keep track. -As a Personal Trainer, I can allow my clients to track their progress but prevent them from accessing other clients information, to allow for privacy. -As a Personal Trainer, I can add various statistics(e.g. Weight, height, age, gender, calories,etc) to each client so that i can easily track and find them. -As a Personal Trainer, I can use the (APP?) to find out which aspect of each client can be improved, so that i can help them improve in fitness. -As a Personal Trainer, i can be alerted if i have a training session with a client in the near future, so that i will not upset clients. -(WH) Must-Have As a Personal Trainer, i can set a goal for the client and obtain the appropriate amount of calories and protein in order to reach the desired goal, so as to assist in grooming the client. - - - Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (unlikely to have) - `*` [width="59%",cols="22%,<23%,<25%,<30%",options="header",] diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index ed6ba8f79ab8..fa0800d55cb9 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -38,7 +38,7 @@ /** * The main entry point to the application. */ -public class hellMainApp extends Application { +public class MainApp extends Application { public static final Version VERSION = new Version(0, 6, 0, true); From 83b218b277b90c2949b572f62045e8edc3832104 Mon Sep 17 00:00:00 2001 From: hypertun Date: Mon, 12 Mar 2018 17:42:19 +0800 Subject: [PATCH 010/227] Added the reference to reused work --- src/main/java/seedu/address/logic/commands/AddCommand.java | 1 + src/main/java/seedu/address/logic/commands/ClearCommand.java | 1 + src/main/java/seedu/address/logic/commands/DeleteCommand.java | 1 + src/main/java/seedu/address/logic/commands/EditCommand.java | 1 + src/main/java/seedu/address/logic/commands/FindCommand.java | 1 + src/main/java/seedu/address/logic/commands/ListCommand.java | 1 + src/main/java/seedu/address/logic/commands/SelectCommand.java | 1 + src/main/java/seedu/address/logic/parser/AddressBookParser.java | 2 +- 8 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index d5de4a572715..014af95df1f9 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -17,6 +17,7 @@ public class AddCommand extends UndoableCommand { public static final String COMMAND_WORD = "add"; + //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component public static final String COMMAND_ALIAS = "a"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index 6d04efaf3295..3b053d7ec426 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -10,6 +10,7 @@ public class ClearCommand extends UndoableCommand { public static final String COMMAND_WORD = "clear"; + //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component public static final String COMMAND_ALIAS = "c"; public static final String MESSAGE_SUCCESS = "Address book has been cleared!"; diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 0cd0fbd860ad..2185900a8356 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -17,6 +17,7 @@ public class DeleteCommand extends UndoableCommand { public static final String COMMAND_WORD = "delete"; + //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component public static final String COMMAND_ALIAS = "d"; public static final String MESSAGE_USAGE = COMMAND_WORD diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 3021c951a5b1..80015e606772 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -34,6 +34,7 @@ public class EditCommand extends UndoableCommand { public static final String COMMAND_WORD = "edit"; + //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component public static final String COMMAND_ALIAS = "e"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified " diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index a73078ed6ea3..fc4c35f6bf06 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -9,6 +9,7 @@ public class FindCommand extends Command { public static final String COMMAND_WORD = "find"; + //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component public static final String COMMAND_ALIAS = "f"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 2631e4dda649..20e3bf931e14 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -8,6 +8,7 @@ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; + //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component public static final String COMMAND_ALIAS = "l"; public static final String MESSAGE_SUCCESS = "Listed all persons"; diff --git a/src/main/java/seedu/address/logic/commands/SelectCommand.java b/src/main/java/seedu/address/logic/commands/SelectCommand.java index 0bc2e3e21485..21651dab9d19 100644 --- a/src/main/java/seedu/address/logic/commands/SelectCommand.java +++ b/src/main/java/seedu/address/logic/commands/SelectCommand.java @@ -15,6 +15,7 @@ public class SelectCommand extends Command { public static final String COMMAND_WORD = "select"; + //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component public static final String COMMAND_ALIAS = "s"; public static final String MESSAGE_USAGE = COMMAND_WORD diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 0716002b8ead..7b48acbf6191 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -47,7 +47,7 @@ public Command parseCommand(String userInput) throws ParseException { final String commandWord = matcher.group("commandWord"); final String arguments = matcher.group("arguments"); switch (commandWord) { - + //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component case AddCommand.COMMAND_WORD: case AddCommand.COMMAND_ALIAS: return new AddCommandParser().parse(arguments); From fad0423a5e6e0646d6e332853024d5a5834d2c80 Mon Sep 17 00:00:00 2001 From: Wenhao Cheng Date: Mon, 12 Mar 2018 20:51:30 +0800 Subject: [PATCH 011/227] Changed AddCommand to be case-insensitive --- src/main/java/seedu/address/model/person/Address.java | 2 +- src/main/java/seedu/address/model/person/Name.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java index 5e981f07790a..8bb3f27e12d2 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/person/Address.java @@ -47,7 +47,7 @@ public String toString() { public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof Address // instanceof handles nulls - && this.value.equals(((Address) other).value)); // state check + && this.value.toLowerCase().equals(((Address) other).value.toLowerCase())); // state check } @Override diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/person/Name.java index 8e632943c4cf..d0570d514860 100644 --- a/src/main/java/seedu/address/model/person/Name.java +++ b/src/main/java/seedu/address/model/person/Name.java @@ -31,6 +31,7 @@ public Name(String name) { this.fullName = name; } + /** * Returns true if a given string is a valid person name. */ @@ -48,7 +49,7 @@ public String toString() { public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof Name // instanceof handles nulls - && this.fullName.equals(((Name) other).fullName)); // state check + && this.fullName.toLowerCase().equals(((Name) other).fullName.toLowerCase())); // state check } @Override From 2ae494380cd9b6cc01714ca6dbfcf0f3a231dffe Mon Sep 17 00:00:00 2001 From: hypertun Date: Tue, 13 Mar 2018 22:40:29 +0800 Subject: [PATCH 012/227] Did a proper reference to other work --- src/main/java/seedu/address/logic/commands/AddCommand.java | 5 ++++- src/main/java/seedu/address/logic/commands/ClearCommand.java | 4 +++- .../java/seedu/address/logic/commands/DeleteCommand.java | 4 +++- src/main/java/seedu/address/logic/commands/EditCommand.java | 4 +++- src/main/java/seedu/address/logic/commands/FindCommand.java | 4 +++- src/main/java/seedu/address/logic/commands/ListCommand.java | 4 +++- .../java/seedu/address/logic/commands/SelectCommand.java | 4 +++- .../java/seedu/address/logic/parser/AddressBookParser.java | 4 +++- 8 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 014af95df1f9..691e89e6a133 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -17,7 +17,10 @@ public class AddCommand extends UndoableCommand { public static final String COMMAND_WORD = "add"; - //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + /** + * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + */ + public static final String COMMAND_ALIAS = "a"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index 3b053d7ec426..3b1f4651aded 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -10,7 +10,9 @@ public class ClearCommand extends UndoableCommand { public static final String COMMAND_WORD = "clear"; - //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + /** + * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + */ public static final String COMMAND_ALIAS = "c"; public static final String MESSAGE_SUCCESS = "Address book has been cleared!"; diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 2185900a8356..d1a188a7a79e 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -17,7 +17,9 @@ public class DeleteCommand extends UndoableCommand { public static final String COMMAND_WORD = "delete"; - //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + /** + * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + */ public static final String COMMAND_ALIAS = "d"; public static final String MESSAGE_USAGE = COMMAND_WORD diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 80015e606772..883f6cac1b57 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -34,7 +34,9 @@ public class EditCommand extends UndoableCommand { public static final String COMMAND_WORD = "edit"; - //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + /** + * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + */ public static final String COMMAND_ALIAS = "e"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified " diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index fc4c35f6bf06..b5dc396b6492 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -9,7 +9,9 @@ public class FindCommand extends Command { public static final String COMMAND_WORD = "find"; - //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + /** + * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + */ public static final String COMMAND_ALIAS = "f"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 20e3bf931e14..d8cf0c5971c9 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -8,7 +8,9 @@ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; - //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + /** + * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + */ public static final String COMMAND_ALIAS = "l"; public static final String MESSAGE_SUCCESS = "Listed all persons"; diff --git a/src/main/java/seedu/address/logic/commands/SelectCommand.java b/src/main/java/seedu/address/logic/commands/SelectCommand.java index 21651dab9d19..49f18db27cdf 100644 --- a/src/main/java/seedu/address/logic/commands/SelectCommand.java +++ b/src/main/java/seedu/address/logic/commands/SelectCommand.java @@ -15,7 +15,9 @@ public class SelectCommand extends Command { public static final String COMMAND_WORD = "select"; - //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + /** + * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + */ public static final String COMMAND_ALIAS = "s"; public static final String MESSAGE_USAGE = COMMAND_WORD diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 7b48acbf6191..f43cdb3f42c5 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -47,7 +47,9 @@ public Command parseCommand(String userInput) throws ParseException { final String commandWord = matcher.group("commandWord"); final String arguments = matcher.group("arguments"); switch (commandWord) { - //Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + /** + * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + */ case AddCommand.COMMAND_WORD: case AddCommand.COMMAND_ALIAS: return new AddCommandParser().parse(arguments); From 59671a4d2834d5e23bf43656e133f889964c2a57 Mon Sep 17 00:00:00 2001 From: hypertun Date: Wed, 14 Mar 2018 10:29:51 +0800 Subject: [PATCH 013/227] Shortened the lines --- src/main/java/seedu/address/logic/commands/AddCommand.java | 3 ++- src/main/java/seedu/address/logic/commands/ClearCommand.java | 3 ++- src/main/java/seedu/address/logic/commands/DeleteCommand.java | 3 ++- src/main/java/seedu/address/logic/commands/EditCommand.java | 3 ++- src/main/java/seedu/address/logic/commands/FindCommand.java | 3 ++- src/main/java/seedu/address/logic/commands/ListCommand.java | 3 ++- src/main/java/seedu/address/logic/commands/SelectCommand.java | 3 ++- .../java/seedu/address/logic/parser/AddressBookParser.java | 3 ++- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 691e89e6a133..4714d1b3f566 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -18,7 +18,8 @@ public class AddCommand extends UndoableCommand { public static final String COMMAND_WORD = "add"; /** - * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + * Adapted from https://nus-cs2103-ay1718s2.github.io/ + * addressbook-level4/DeveloperGuide.html#improving-each-component */ public static final String COMMAND_ALIAS = "a"; diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index 3b1f4651aded..9bf968fe1aba 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -11,7 +11,8 @@ public class ClearCommand extends UndoableCommand { public static final String COMMAND_WORD = "clear"; /** - * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + * Adapted from https://nus-cs2103-ay1718s2.github.io/ + * addressbook-level4/DeveloperGuide.html#improving-each-component */ public static final String COMMAND_ALIAS = "c"; public static final String MESSAGE_SUCCESS = "Address book has been cleared!"; diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index d1a188a7a79e..27b426434102 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -18,7 +18,8 @@ public class DeleteCommand extends UndoableCommand { public static final String COMMAND_WORD = "delete"; /** - * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + * Adapted from https://nus-cs2103-ay1718s2.github.io/ + * addressbook-level4/DeveloperGuide.html#improving-each-component */ public static final String COMMAND_ALIAS = "d"; diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 883f6cac1b57..5d4b67d62cb3 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -35,7 +35,8 @@ public class EditCommand extends UndoableCommand { public static final String COMMAND_WORD = "edit"; /** - * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + * Adapted from https://nus-cs2103-ay1718s2.github.io/ + * addressbook-level4/DeveloperGuide.html#improving-each-component */ public static final String COMMAND_ALIAS = "e"; diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index b5dc396b6492..1e9c72bc4413 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -10,7 +10,8 @@ public class FindCommand extends Command { public static final String COMMAND_WORD = "find"; /** - * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + * Adapted from https://nus-cs2103-ay1718s2.github.io/ + * addressbook-level4/DeveloperGuide.html#improving-each-component */ public static final String COMMAND_ALIAS = "f"; diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index d8cf0c5971c9..73cce4bceda4 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -9,7 +9,8 @@ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; /** - * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + * Adapted from https://nus-cs2103-ay1718s2.github.io/ + * addressbook-level4/DeveloperGuide.html#improving-each-component */ public static final String COMMAND_ALIAS = "l"; diff --git a/src/main/java/seedu/address/logic/commands/SelectCommand.java b/src/main/java/seedu/address/logic/commands/SelectCommand.java index 49f18db27cdf..73178c4b06c7 100644 --- a/src/main/java/seedu/address/logic/commands/SelectCommand.java +++ b/src/main/java/seedu/address/logic/commands/SelectCommand.java @@ -16,7 +16,8 @@ public class SelectCommand extends Command { public static final String COMMAND_WORD = "select"; /** - * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + * Adapted from https://nus-cs2103-ay1718s2.github.io/ + * addressbook-level4/DeveloperGuide.html#improving-each-component */ public static final String COMMAND_ALIAS = "s"; diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index f43cdb3f42c5..8c8628ffc3bc 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -48,7 +48,8 @@ public Command parseCommand(String userInput) throws ParseException { final String arguments = matcher.group("arguments"); switch (commandWord) { /** - * Adapted from https://nus-cs2103-ay1718s2.github.io/addressbook-level4/DeveloperGuide.html#improving-each-component + * Adapted from https://nus-cs2103-ay1718s2.github.io/ + * addressbook-level4/DeveloperGuide.html#improving-each-component */ case AddCommand.COMMAND_WORD: case AddCommand.COMMAND_ALIAS: From fc018cc4c19bb77c621e571e47e7f5887238d8f0 Mon Sep 17 00:00:00 2001 From: hypertun Date: Wed, 14 Mar 2018 10:36:30 +0800 Subject: [PATCH 014/227] Indentation error was corrected --- .../seedu/address/logic/parser/AddressBookParser.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 8c8628ffc3bc..889d36180f85 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -47,10 +47,10 @@ public Command parseCommand(String userInput) throws ParseException { final String commandWord = matcher.group("commandWord"); final String arguments = matcher.group("arguments"); switch (commandWord) { - /** - * Adapted from https://nus-cs2103-ay1718s2.github.io/ - * addressbook-level4/DeveloperGuide.html#improving-each-component - */ + /** + * Adapted from https://nus-cs2103-ay1718s2.github.io/ + * addressbook-level4/DeveloperGuide.html#improving-each-component + */ case AddCommand.COMMAND_WORD: case AddCommand.COMMAND_ALIAS: return new AddCommandParser().parse(arguments); From 73d81302e46724646d9c4d36cd21d8462943826c Mon Sep 17 00:00:00 2001 From: Wenhao Cheng Date: Wed, 14 Mar 2018 15:27:14 +0800 Subject: [PATCH 015/227] Revert "Changed AddCommand to be case-insensitive" This reverts commit fad0423a5e6e0646d6e332853024d5a5834d2c80. --- src/main/java/seedu/address/model/person/Address.java | 2 +- src/main/java/seedu/address/model/person/Name.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java index 8bb3f27e12d2..5e981f07790a 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/person/Address.java @@ -47,7 +47,7 @@ public String toString() { public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof Address // instanceof handles nulls - && this.value.toLowerCase().equals(((Address) other).value.toLowerCase())); // state check + && this.value.equals(((Address) other).value)); // state check } @Override diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/person/Name.java index d0570d514860..8e632943c4cf 100644 --- a/src/main/java/seedu/address/model/person/Name.java +++ b/src/main/java/seedu/address/model/person/Name.java @@ -31,7 +31,6 @@ public Name(String name) { this.fullName = name; } - /** * Returns true if a given string is a valid person name. */ @@ -49,7 +48,7 @@ public String toString() { public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof Name // instanceof handles nulls - && this.fullName.toLowerCase().equals(((Name) other).fullName.toLowerCase())); // state check + && this.fullName.equals(((Name) other).fullName)); // state check } @Override From 276f2a5f7334f438bf89e2ec1caddff2c6629588 Mon Sep 17 00:00:00 2001 From: Wenhao Cheng Date: Wed, 14 Mar 2018 15:36:21 +0800 Subject: [PATCH 016/227] Change AddCommand to be case-insensitive for Name and Address --- src/main/java/seedu/address/model/person/Address.java | 6 ++++++ src/main/java/seedu/address/model/person/Name.java | 6 ++++++ src/main/java/seedu/address/model/person/Person.java | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java index 5e981f07790a..2d2f5c0c5132 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/person/Address.java @@ -50,6 +50,12 @@ public boolean equals(Object other) { && this.value.equals(((Address) other).value)); // state check } + public boolean alphabeticallyEquals(Object other) { + return other == this // short circuit if same object + || (other instanceof Address // instanceof handles nulls + && this.value.toLowerCase().equals(((Address) other).value)); // state check + } + @Override public int hashCode() { return value.hashCode(); diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/person/Name.java index 8e632943c4cf..a5a2e98611c1 100644 --- a/src/main/java/seedu/address/model/person/Name.java +++ b/src/main/java/seedu/address/model/person/Name.java @@ -51,6 +51,12 @@ public boolean equals(Object other) { && this.fullName.equals(((Name) other).fullName)); // state check } + public boolean alphabeticallyEquals(Object other) { + return other == this // short circuit if same object + || (other instanceof Name // instanceof handles nulls + && this.fullName.toLowerCase().equals(((Name) other).fullName.toLowerCase())); // state check + } + @Override public int hashCode() { return fullName.hashCode(); diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index ec9f2aa5e919..42d6ca78c0ac 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -70,10 +70,10 @@ public boolean equals(Object other) { } Person otherPerson = (Person) other; - return otherPerson.getName().equals(this.getName()) + return otherPerson.getName().alphabeticallyEquals(this.getName()) && otherPerson.getPhone().equals(this.getPhone()) && otherPerson.getEmail().equals(this.getEmail()) - && otherPerson.getAddress().equals(this.getAddress()); + && otherPerson.getAddress().alphabeticallyEquals(this.getAddress()); } @Override From 0f5791a6e0d47e7f757fdff8ab82eb24fa0d1471 Mon Sep 17 00:00:00 2001 From: Wenhao Cheng Date: Wed, 14 Mar 2018 15:43:04 +0800 Subject: [PATCH 017/227] Insert javadoc comments for alphabeticallyEquals methods --- .../java/seedu/address/model/person/Address.java | 15 +++++++++------ .../java/seedu/address/model/person/Name.java | 14 ++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java index 2d2f5c0c5132..91528d6080b3 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/person/Address.java @@ -38,6 +38,15 @@ public static boolean isValidAddress(String test) { return test.matches(ADDRESS_VALIDATION_REGEX); } + /** + * Returns true if two Addresses in comparison are alphabetically the same (regardless of case). + */ + public boolean alphabeticallyEquals(Object other) { + return other == this // short circuit if same object + || (other instanceof Address // instanceof handles nulls + && this.value.toLowerCase().equals(((Address) other).value)); // state check + } + @Override public String toString() { return value; @@ -50,12 +59,6 @@ public boolean equals(Object other) { && this.value.equals(((Address) other).value)); // state check } - public boolean alphabeticallyEquals(Object other) { - return other == this // short circuit if same object - || (other instanceof Address // instanceof handles nulls - && this.value.toLowerCase().equals(((Address) other).value)); // state check - } - @Override public int hashCode() { return value.hashCode(); diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/person/Name.java index a5a2e98611c1..333e22e6d96b 100644 --- a/src/main/java/seedu/address/model/person/Name.java +++ b/src/main/java/seedu/address/model/person/Name.java @@ -38,6 +38,14 @@ public static boolean isValidName(String test) { return test.matches(NAME_VALIDATION_REGEX); } + /** + * Returns true if two Names in comparison are alphabetically the same (regardless of case). + */ + public boolean alphabeticallyEquals(Object other) { + return other == this // short circuit if same object + || (other instanceof Name // instanceof handles nulls + && this.fullName.toLowerCase().equals(((Name) other).fullName.toLowerCase())); // state check + } @Override public String toString() { @@ -51,12 +59,6 @@ public boolean equals(Object other) { && this.fullName.equals(((Name) other).fullName)); // state check } - public boolean alphabeticallyEquals(Object other) { - return other == this // short circuit if same object - || (other instanceof Name // instanceof handles nulls - && this.fullName.toLowerCase().equals(((Name) other).fullName.toLowerCase())); // state check - } - @Override public int hashCode() { return fullName.hashCode(); From 6ed5b26b1687f7b900b0540a459b41b03e791658 Mon Sep 17 00:00:00 2001 From: Wenhao Cheng Date: Wed, 14 Mar 2018 15:51:03 +0800 Subject: [PATCH 018/227] Removed changes in Developer Guide --- docs/DeveloperGuide.adoc | 54 +--------------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 8756c7084552..1733af113b29 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -844,59 +844,7 @@ Use case ends. + Use case resumes at step 2. - -=== Use case: Add person - -*MSS* - -1. User requests to add person -2. AddressBook prompts for data input -3. User inputs data for person to be added -4. AddressBook adds the new person -+ -Use case ends. - -*Extensions* - -[none] -* 3a. Person of the same name is already in AddressBook -+ -[none] -** 3a1. AddressBook shows an error message. -+ -Use case resumes at step 2. - -=== Use case: Add goal for person - -*MSS* - -1. User requests to add goal -2. AddressBook prompts for data input -3. User inputs person name and goal to be added -4. AddressBook adds the new goal for the person -+ -Use case ends. - -*Extensions* - -[none] -* 3a. The given index is invalid. -+ -[none] -** 3a1. AddressBook shows an error message. -+ -Use case resumes at step 2. - -[none] -* 3b. The given goal is empty. -+ -[none] -** 3b1. AddressBook shows an error message. -+ -Use case resumes at step 2. - - - +_{More to be added}_ [appendix] == Non Functional Requirements From a55528b861ae4c7c533c0bd6fe28a4e7dda75a75 Mon Sep 17 00:00:00 2001 From: wayneong95 Date: Wed, 14 Mar 2018 16:08:29 +0800 Subject: [PATCH 019/227] Added a weight attribute to store weight for the person --- .../seedu/address/model/person/Person.java | 15 ++++-- .../seedu/address/model/person/Weight.java | 53 +++++++++++++++++++ .../address/model/person/WeightTest.java | 41 ++++++++++++++ 3 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 src/main/java/seedu/address/model/person/Weight.java create mode 100644 src/test/java/seedu/address/model/person/WeightTest.java diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index ec9f2aa5e919..3d1e3f5503b4 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -19,18 +19,20 @@ public class Person { private final Phone phone; private final Email email; private final Address address; + private final Weight weight; private final UniqueTagList tags; /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Address address, Set tags) { - requireAllNonNull(name, phone, email, address, tags); + public Person(Name name, Phone phone, Email email, Address address, Weight weight, Set tags) { + requireAllNonNull(name, phone, email, address, weight, tags); this.name = name; this.phone = phone; this.email = email; this.address = address; + this.weight = weight; // protect internal tags from changes in the arg list this.tags = new UniqueTagList(tags); } @@ -51,6 +53,8 @@ public Address getAddress() { return address; } + public Weight getWeight() { return weight; } + /** * Returns an immutable tag set, which throws {@code UnsupportedOperationException} * if modification is attempted. @@ -73,13 +77,14 @@ public boolean equals(Object other) { return otherPerson.getName().equals(this.getName()) && otherPerson.getPhone().equals(this.getPhone()) && otherPerson.getEmail().equals(this.getEmail()) - && otherPerson.getAddress().equals(this.getAddress()); + && otherPerson.getAddress().equals(this.getAddress()) + && otherPerson.getWeight().equals(this.getWeight()); } @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, weight, tags); } @Override @@ -92,6 +97,8 @@ public String toString() { .append(getEmail()) .append(" Address: ") .append(getAddress()) + .append(" Weight: ") + .append(getWeight()) .append(" Tags: "); getTags().forEach(builder::append); return builder.toString(); diff --git a/src/main/java/seedu/address/model/person/Weight.java b/src/main/java/seedu/address/model/person/Weight.java new file mode 100644 index 000000000000..b56088ad26d7 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Weight.java @@ -0,0 +1,53 @@ +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a Person's weight (in Kg) in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidWeight(String)} + */ +public class Weight { + + + public static final String MESSAGE_WEIGHT_CONSTRAINTS = + "Weight(in Kg) can only contain numbers and decimals, and should be at least 2 digits long"; + public static final String WEIGHT_VALIDATION_REGEX = "\\d{2,}(\\.\\d+)?"; + public final String value; + + /** + * Constructs a {@code Weight}. + * + * @param weight A valid weight (in Kg). + */ + public Weight(String weight) { + requireNonNull(weight); + checkArgument(isValidWeight(weight), MESSAGE_WEIGHT_CONSTRAINTS); + this.value = weight; + } + + /** + * Returns true if a given string is a valid weight. + */ + public static boolean isValidWeight(String test) { + return test.matches(WEIGHT_VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Weight // instanceof handles nulls + && this.value.equals(((Weight) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} diff --git a/src/test/java/seedu/address/model/person/WeightTest.java b/src/test/java/seedu/address/model/person/WeightTest.java new file mode 100644 index 000000000000..c721cbbfc048 --- /dev/null +++ b/src/test/java/seedu/address/model/person/WeightTest.java @@ -0,0 +1,41 @@ +package seedu.address.model.person; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import seedu.address.testutil.Assert; + +public class PhoneTest { + + @Test + public void constructor_null_throwsNullPointerException() { + Assert.assertThrows(NullPointerException.class, () -> new Phone(null)); + } + + @Test + public void constructor_invalidPhone_throwsIllegalArgumentException() { + String invalidPhone = ""; + Assert.assertThrows(IllegalArgumentException.class, () -> new Phone(invalidPhone)); + } + + @Test + public void isValidPhone() { + // null phone number + Assert.assertThrows(NullPointerException.class, () -> Phone.isValidPhone(null)); + + // invalid phone numbers + assertFalse(Phone.isValidPhone("")); // empty string + assertFalse(Phone.isValidPhone(" ")); // spaces only + assertFalse(Phone.isValidPhone("91")); // less than 3 numbers + assertFalse(Phone.isValidPhone("phone")); // non-numeric + assertFalse(Phone.isValidPhone("9011p041")); // alphabets within digits + assertFalse(Phone.isValidPhone("9312 1534")); // spaces within digits + + // valid phone numbers + assertTrue(Phone.isValidPhone("911")); // exactly 3 numbers + assertTrue(Phone.isValidPhone("93121534")); + assertTrue(Phone.isValidPhone("124293842033123")); // long phone numbers + } +} From a27985831dadb8a643fab73502b51365da8a819f Mon Sep 17 00:00:00 2001 From: wayneong95 Date: Wed, 14 Mar 2018 16:09:54 +0800 Subject: [PATCH 020/227] Edit the tests to fit the addition of the weight attribute --- .../address/commons/util/XmlUtilTest.java | 7 ++- .../logic/commands/CommandTestUtil.java | 10 +++- .../logic/parser/AddCommandParserTest.java | 58 ++++++++++++------- .../logic/parser/EditCommandParserTest.java | 15 ++++- .../address/model/person/WeightTest.java | 44 +++++++------- .../address/storage/XmlAdaptedPersonTest.java | 36 +++++++++--- .../systemtests/AddCommandSystemTest.java | 43 ++++++++------ .../systemtests/EditCommandSystemTest.java | 21 +++++-- 8 files changed, 148 insertions(+), 86 deletions(-) diff --git a/src/test/java/seedu/address/commons/util/XmlUtilTest.java b/src/test/java/seedu/address/commons/util/XmlUtilTest.java index 56b6ef8f40d3..45d2c1430d67 100644 --- a/src/test/java/seedu/address/commons/util/XmlUtilTest.java +++ b/src/test/java/seedu/address/commons/util/XmlUtilTest.java @@ -39,6 +39,7 @@ public class XmlUtilTest { private static final String VALID_PHONE = "9482424"; private static final String VALID_EMAIL = "hans@example"; private static final String VALID_ADDRESS = "4th street"; + private static final String VALID_WEIGHT = "55.5"; private static final List VALID_TAGS = Collections.singletonList(new XmlAdaptedTag("friends")); @Rule @@ -80,7 +81,7 @@ public void xmlAdaptedPersonFromFile_fileWithMissingPersonField_validResult() th XmlAdaptedPerson actualPerson = XmlUtil.getDataFromFile( MISSING_PERSON_FIELD_FILE, XmlAdaptedPersonWithRootElement.class); XmlAdaptedPerson expectedPerson = new XmlAdaptedPerson( - null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); assertEquals(expectedPerson, actualPerson); } @@ -89,7 +90,7 @@ public void xmlAdaptedPersonFromFile_fileWithInvalidPersonField_validResult() th XmlAdaptedPerson actualPerson = XmlUtil.getDataFromFile( INVALID_PERSON_FIELD_FILE, XmlAdaptedPersonWithRootElement.class); XmlAdaptedPerson expectedPerson = new XmlAdaptedPerson( - VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); assertEquals(expectedPerson, actualPerson); } @@ -98,7 +99,7 @@ public void xmlAdaptedPersonFromFile_fileWithValidPerson_validResult() throws Ex XmlAdaptedPerson actualPerson = XmlUtil.getDataFromFile( VALID_PERSON_FILE, XmlAdaptedPersonWithRootElement.class); XmlAdaptedPerson expectedPerson = new XmlAdaptedPerson( - VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); assertEquals(expectedPerson, actualPerson); } diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 9a5679cc29b6..d53a77028d6f 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -8,6 +8,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.PREFIX_WEIGHT; import java.util.ArrayList; import java.util.Arrays; @@ -37,6 +38,8 @@ public class CommandTestUtil { public static final String VALID_EMAIL_BOB = "bob@example.com"; public static final String VALID_ADDRESS_AMY = "Block 312, Amy Street 1"; public static final String VALID_ADDRESS_BOB = "Block 123, Bobby Street 3"; + public static final String VALID_WEIGHT_AMY = "55.5"; + public static final String VALID_WEIGHT_BOB = "55.5"; public static final String VALID_TAG_HUSBAND = "husband"; public static final String VALID_TAG_FRIEND = "friend"; @@ -48,6 +51,8 @@ public class CommandTestUtil { public static final String EMAIL_DESC_BOB = " " + PREFIX_EMAIL + VALID_EMAIL_BOB; public static final String ADDRESS_DESC_AMY = " " + PREFIX_ADDRESS + VALID_ADDRESS_AMY; public static final String ADDRESS_DESC_BOB = " " + PREFIX_ADDRESS + VALID_ADDRESS_BOB; + public static final String WEIGHT_DESC_AMY = " " + PREFIX_WEIGHT + VALID_WEIGHT_AMY; + public static final String WEIGHT_DESC_BOB = " " + PREFIX_WEIGHT + VALID_WEIGHT_BOB; public static final String TAG_DESC_FRIEND = " " + PREFIX_TAG + VALID_TAG_FRIEND; public static final String TAG_DESC_HUSBAND = " " + PREFIX_TAG + VALID_TAG_HUSBAND; @@ -55,6 +60,7 @@ public class CommandTestUtil { public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses + public static final String INVALID_WEIGHT_DESC = " " + PREFIX_WEIGHT; // empty string not allowed for weight public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags public static final String PREAMBLE_WHITESPACE = "\t \r \n"; @@ -65,10 +71,10 @@ public class CommandTestUtil { static { DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) - .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) + .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY) .withTags(VALID_TAG_FRIEND).build(); DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) - .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) + .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); } diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index c9a350c09657..b32a64b875de 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -10,6 +10,7 @@ import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_TAG_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_WEIGHT_DESC; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY; @@ -28,6 +29,10 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_WEIGHT_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_WEIGHT_BOB; +import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_BOB; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; @@ -39,6 +44,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.tag.Tag; import seedu.address.testutil.PersonBuilder; @@ -48,33 +54,33 @@ public class AddCommandParserTest { @Test public void parse_allFieldsPresent_success() { Person expectedPerson = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_FRIEND).build(); + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB).withTags(VALID_TAG_FRIEND).build(); // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple names - last name accepted assertParseSuccess(parser, NAME_DESC_AMY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple phones - last phone accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple emails - last email accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_AMY + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple addresses - last address accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_AMY - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple tags - all accepted Person expectedPersonMultipleTags = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB) .withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND).build(); - assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, new AddCommand(expectedPersonMultipleTags)); } @@ -82,8 +88,8 @@ public void parse_allFieldsPresent_success() { public void parse_optionalFieldsMissing_success() { // zero tags Person expectedPerson = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) - .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags().build(); - assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY, + .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY).withTags().build(); + assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY, new AddCommand(expectedPerson)); } @@ -92,54 +98,62 @@ public void parse_compulsoryFieldMissing_failure() { String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE); // missing name prefix - assertParseFailure(parser, VALID_NAME_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB, + assertParseFailure(parser, VALID_NAME_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB, expectedMessage); // missing phone prefix - assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB, + assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB, expectedMessage); // missing email prefix - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB + ADDRESS_DESC_BOB, + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB, expectedMessage); // missing address prefix - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + VALID_ADDRESS_BOB, + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + VALID_ADDRESS_BOB + WEIGHT_DESC_BOB, + expectedMessage); + + // missing weight prefix + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + VALID_WEIGHT_BOB, expectedMessage); // all prefixes missing - assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB + VALID_ADDRESS_BOB, + assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB + VALID_ADDRESS_BOB + VALID_WEIGHT_BOB, expectedMessage); } @Test public void parse_invalidValue_failure() { // invalid name - assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Name.MESSAGE_NAME_CONSTRAINTS); // invalid phone - assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Phone.MESSAGE_PHONE_CONSTRAINTS); // invalid email - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Email.MESSAGE_EMAIL_CONSTRAINTS); // invalid address - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_ADDRESS_CONSTRAINTS); + // invalid weight + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + INVALID_WEIGHT_DESC + + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Weight.MESSAGE_WEIGHT_CONSTRAINTS); + // invalid tag - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + INVALID_TAG_DESC + VALID_TAG_FRIEND, Tag.MESSAGE_TAG_CONSTRAINTS); // two invalid values, only first invalid value reported - assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC, + assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC + WEIGHT_DESC_BOB, Name.MESSAGE_NAME_CONSTRAINTS); // non-empty preamble - assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + WEIGHT_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 24c138b41a7f..b4a17daf095a 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -10,6 +10,7 @@ import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_TAG_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_WEIGHT_DESC; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB; @@ -24,6 +25,8 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_WEIGHT_AMY; +import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_AMY; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; @@ -40,6 +43,7 @@ import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.tag.Tag; import seedu.address.testutil.EditPersonDescriptorBuilder; @@ -85,6 +89,7 @@ public void parse_invalidValue_failure() { assertParseFailure(parser, "1" + INVALID_PHONE_DESC, Phone.MESSAGE_PHONE_CONSTRAINTS); // invalid phone assertParseFailure(parser, "1" + INVALID_EMAIL_DESC, Email.MESSAGE_EMAIL_CONSTRAINTS); // invalid email assertParseFailure(parser, "1" + INVALID_ADDRESS_DESC, Address.MESSAGE_ADDRESS_CONSTRAINTS); // invalid address + assertParseFailure(parser, "1" + INVALID_WEIGHT_DESC, Weight.MESSAGE_WEIGHT_CONSTRAINTS); // invalid weight assertParseFailure(parser, "1" + INVALID_TAG_DESC, Tag.MESSAGE_TAG_CONSTRAINTS); // invalid tag // invalid phone followed by valid email @@ -109,10 +114,10 @@ public void parse_invalidValue_failure() { public void parse_allFieldsSpecified_success() { Index targetIndex = INDEX_SECOND_PERSON; String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + TAG_DESC_HUSBAND - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NAME_DESC_AMY + TAG_DESC_FRIEND; + + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY + NAME_DESC_AMY + TAG_DESC_FRIEND; EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) - .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) + .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); @@ -158,6 +163,12 @@ public void parse_oneFieldSpecified_success() { expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); + // weight + userInput = targetIndex.getOneBased() + WEIGHT_DESC_AMY; + descriptor = new EditPersonDescriptorBuilder().withWeight(VALID_WEIGHT_AMY).build(); + expectedCommand = new EditCommand(targetIndex, descriptor); + assertParseSuccess(parser, userInput, expectedCommand); + // tags userInput = targetIndex.getOneBased() + TAG_DESC_FRIEND; descriptor = new EditPersonDescriptorBuilder().withTags(VALID_TAG_FRIEND).build(); diff --git a/src/test/java/seedu/address/model/person/WeightTest.java b/src/test/java/seedu/address/model/person/WeightTest.java index c721cbbfc048..0465002ada90 100644 --- a/src/test/java/seedu/address/model/person/WeightTest.java +++ b/src/test/java/seedu/address/model/person/WeightTest.java @@ -1,41 +1,39 @@ package seedu.address.model.person; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import org.junit.Test; - import seedu.address.testutil.Assert; -public class PhoneTest { +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class WeightTest { @Test public void constructor_null_throwsNullPointerException() { - Assert.assertThrows(NullPointerException.class, () -> new Phone(null)); + Assert.assertThrows(NullPointerException.class, () -> new Weight(null)); } @Test - public void constructor_invalidPhone_throwsIllegalArgumentException() { - String invalidPhone = ""; - Assert.assertThrows(IllegalArgumentException.class, () -> new Phone(invalidPhone)); + public void constructor_invalidWeight_throwsIllegalArgumentException() { + String invalidWeight = ""; + Assert.assertThrows(IllegalArgumentException.class, () -> new Weight(invalidWeight)); } @Test - public void isValidPhone() { - // null phone number - Assert.assertThrows(NullPointerException.class, () -> Phone.isValidPhone(null)); - - // invalid phone numbers - assertFalse(Phone.isValidPhone("")); // empty string - assertFalse(Phone.isValidPhone(" ")); // spaces only - assertFalse(Phone.isValidPhone("91")); // less than 3 numbers - assertFalse(Phone.isValidPhone("phone")); // non-numeric - assertFalse(Phone.isValidPhone("9011p041")); // alphabets within digits - assertFalse(Phone.isValidPhone("9312 1534")); // spaces within digits + public void isValidWeight() { + // null weight + Assert.assertThrows(NullPointerException.class, () -> Weight.isValidWeight(null)); + + // invalid weight + assertFalse(Weight.isValidWeight("")); // empty string + assertFalse(Weight.isValidWeight(" ")); // spaces only + assertFalse(Weight.isValidWeight("weight")); // non-numeric + assertFalse(Weight.isValidWeight("9p.2")); // alphabets within digits + assertFalse(Weight.isValidWeight("9 3")); // spaces within digits // valid phone numbers - assertTrue(Phone.isValidPhone("911")); // exactly 3 numbers - assertTrue(Phone.isValidPhone("93121534")); - assertTrue(Phone.isValidPhone("124293842033123")); // long phone numbers + assertTrue(Weight.isValidWeight("91.1")); // exactly 3 numbers + assertTrue(Weight.isValidWeight("95")); + assertTrue(Weight.isValidWeight("105")); // heavy weight } } diff --git a/src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java b/src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java index c3c91a5c27a7..5cb99b3573f0 100644 --- a/src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java @@ -15,6 +15,7 @@ import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.testutil.Assert; public class XmlAdaptedPersonTest { @@ -22,12 +23,14 @@ public class XmlAdaptedPersonTest { private static final String INVALID_PHONE = "+651234"; private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; + private static final String INVALID_WEIGHT = "sss"; private static final String INVALID_TAG = "#friend"; private static final String VALID_NAME = BENSON.getName().toString(); private static final String VALID_PHONE = BENSON.getPhone().toString(); private static final String VALID_EMAIL = BENSON.getEmail().toString(); private static final String VALID_ADDRESS = BENSON.getAddress().toString(); + private static final String VALID_WEIGHT = BENSON.getWeight().toString(); private static final List VALID_TAGS = BENSON.getTags().stream() .map(XmlAdaptedTag::new) .collect(Collectors.toList()); @@ -41,14 +44,14 @@ public void toModelType_validPersonDetails_returnsPerson() throws Exception { @Test public void toModelType_invalidName_throwsIllegalValueException() { XmlAdaptedPerson person = - new XmlAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + new XmlAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); String expectedMessage = Name.MESSAGE_NAME_CONSTRAINTS; Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullName_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + XmlAdaptedPerson person = new XmlAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -56,14 +59,14 @@ public void toModelType_nullName_throwsIllegalValueException() { @Test public void toModelType_invalidPhone_throwsIllegalValueException() { XmlAdaptedPerson person = - new XmlAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + new XmlAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); String expectedMessage = Phone.MESSAGE_PHONE_CONSTRAINTS; Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullPhone_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -71,14 +74,14 @@ public void toModelType_nullPhone_throwsIllegalValueException() { @Test public void toModelType_invalidEmail_throwsIllegalValueException() { XmlAdaptedPerson person = - new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); String expectedMessage = Email.MESSAGE_EMAIL_CONSTRAINTS; Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullEmail_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_TAGS); + XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -86,24 +89,39 @@ public void toModelType_nullEmail_throwsIllegalValueException() { @Test public void toModelType_invalidAddress_throwsIllegalValueException() { XmlAdaptedPerson person = - new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, VALID_TAGS); + new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); String expectedMessage = Address.MESSAGE_ADDRESS_CONSTRAINTS; Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullAddress_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_TAGS); + XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_WEIGHT, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } + @Test + public void toModelType_invalidWeight_throwsIllegalValueException() { + XmlAdaptedPerson person = + new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, INVALID_WEIGHT, VALID_TAGS); + String expectedMessage = Weight.MESSAGE_WEIGHT_CONSTRAINTS; + Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + } + + @Test + public void toModelType_nullWeight_throwsIllegalValueException() { + XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, null, VALID_TAGS); + String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Weight.class.getSimpleName()); + Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + } + @Test public void toModelType_invalidTags_throwsIllegalValueException() { List invalidTags = new ArrayList<>(VALID_TAGS); invalidTags.add(new XmlAdaptedTag(INVALID_TAG)); XmlAdaptedPerson person = - new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, invalidTags); + new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, invalidTags); Assert.assertThrows(IllegalValueException.class, person::toModelType); } diff --git a/src/test/java/systemtests/AddCommandSystemTest.java b/src/test/java/systemtests/AddCommandSystemTest.java index 3254b60154c4..68ad4851af58 100644 --- a/src/test/java/systemtests/AddCommandSystemTest.java +++ b/src/test/java/systemtests/AddCommandSystemTest.java @@ -3,9 +3,12 @@ import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_WEIGHT_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; @@ -24,6 +27,8 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_WEIGHT_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_WEIGHT_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.testutil.TypicalPersons.ALICE; @@ -65,7 +70,7 @@ public void add() throws Exception { */ Person toAdd = AMY; String command = " " + AddCommand.COMMAND_WORD + " " + NAME_DESC_AMY + " " + PHONE_DESC_AMY + " " - + EMAIL_DESC_AMY + " " + ADDRESS_DESC_AMY + " " + TAG_DESC_FRIEND + " "; + + EMAIL_DESC_AMY + " " + ADDRESS_DESC_AMY + " " + WEIGHT_DESC_AMY + " " + TAG_DESC_FRIEND + " "; assertCommandSuccess(command, toAdd); /* Case: undo adding Amy to the list -> Amy deleted */ @@ -81,29 +86,29 @@ public void add() throws Exception { /* Case: add a person with all fields same as another person in the address book except name -> added */ toAdd = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) - .withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); - command = AddCommand.COMMAND_WORD + NAME_DESC_BOB + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + .withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY).withTags(VALID_TAG_FRIEND).build(); + command = AddCommand.COMMAND_WORD + NAME_DESC_BOB + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); /* Case: add a person with all fields same as another person in the address book except phone -> added */ toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY) - .withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + .withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY).withTags(VALID_TAG_FRIEND).build(); + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); /* Case: add a person with all fields same as another person in the address book except email -> added */ toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_BOB) - .withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_BOB + ADDRESS_DESC_AMY + .withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY).withTags(VALID_TAG_FRIEND).build(); + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_BOB + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); /* Case: add a person with all fields same as another person in the address book except address -> added */ toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) - .withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_FRIEND).build(); - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_BOB + .withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_AMY).withTags(VALID_TAG_FRIEND).build(); + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_BOB + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); @@ -113,7 +118,7 @@ public void add() throws Exception { /* Case: add a person with tags, command with parameters in random order -> added */ toAdd = BOB; - command = AddCommand.COMMAND_WORD + TAG_DESC_FRIEND + PHONE_DESC_BOB + ADDRESS_DESC_BOB + NAME_DESC_BOB + command = AddCommand.COMMAND_WORD + TAG_DESC_FRIEND + PHONE_DESC_BOB + ADDRESS_DESC_BOB + NAME_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + EMAIL_DESC_BOB; assertCommandSuccess(command, toAdd); @@ -146,19 +151,19 @@ public void add() throws Exception { assertCommandFailure(command, AddCommand.MESSAGE_DUPLICATE_PERSON); /* Case: missing name -> rejected */ - command = AddCommand.COMMAND_WORD + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY; + command = AddCommand.COMMAND_WORD + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; assertCommandFailure(command, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); /* Case: missing phone -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; assertCommandFailure(command, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); /* Case: missing email -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + ADDRESS_DESC_AMY; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; assertCommandFailure(command, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); /* Case: missing address -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + WEIGHT_DESC_AMY; assertCommandFailure(command, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); /* Case: invalid keyword -> rejected */ @@ -166,23 +171,23 @@ public void add() throws Exception { assertCommandFailure(command, Messages.MESSAGE_UNKNOWN_COMMAND); /* Case: invalid name -> rejected */ - command = AddCommand.COMMAND_WORD + INVALID_NAME_DESC + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY; + command = AddCommand.COMMAND_WORD + INVALID_NAME_DESC + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; assertCommandFailure(command, Name.MESSAGE_NAME_CONSTRAINTS); /* Case: invalid phone -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + INVALID_PHONE_DESC + EMAIL_DESC_AMY + ADDRESS_DESC_AMY; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + INVALID_PHONE_DESC + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; assertCommandFailure(command, Phone.MESSAGE_PHONE_CONSTRAINTS); /* Case: invalid email -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + INVALID_EMAIL_DESC + ADDRESS_DESC_AMY; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + INVALID_EMAIL_DESC + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; assertCommandFailure(command, Email.MESSAGE_EMAIL_CONSTRAINTS); /* Case: invalid address -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + INVALID_ADDRESS_DESC; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + INVALID_ADDRESS_DESC + WEIGHT_DESC_AMY; assertCommandFailure(command, Address.MESSAGE_ADDRESS_CONSTRAINTS); /* Case: invalid tag -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY + INVALID_TAG_DESC; assertCommandFailure(command, Tag.MESSAGE_TAG_CONSTRAINTS); } diff --git a/src/test/java/systemtests/EditCommandSystemTest.java b/src/test/java/systemtests/EditCommandSystemTest.java index 820933203dd9..a7a5f71b3dfb 100644 --- a/src/test/java/systemtests/EditCommandSystemTest.java +++ b/src/test/java/systemtests/EditCommandSystemTest.java @@ -11,6 +11,7 @@ import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_TAG_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_WEIGHT_DESC; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY; @@ -23,6 +24,9 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_WEIGHT_BOB; +import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_BOB; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; @@ -43,6 +47,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.person.exceptions.PersonNotFoundException; import seedu.address.model.tag.Tag; @@ -62,9 +67,9 @@ public void edit() throws Exception { */ Index index = INDEX_FIRST_PERSON; String command = " " + EditCommand.COMMAND_WORD + " " + index.getOneBased() + " " + NAME_DESC_BOB + " " - + PHONE_DESC_BOB + " " + EMAIL_DESC_BOB + " " + ADDRESS_DESC_BOB + " " + TAG_DESC_HUSBAND + " "; + + PHONE_DESC_BOB + " " + EMAIL_DESC_BOB + " " + ADDRESS_DESC_BOB + " " + WEIGHT_DESC_BOB + " " + TAG_DESC_HUSBAND + " "; Person editedPerson = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND).build(); + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB).withTags(VALID_TAG_HUSBAND).build(); assertCommandSuccess(command, index, editedPerson); /* Case: undo editing the last person in the list -> last person restored */ @@ -81,7 +86,7 @@ public void edit() throws Exception { /* Case: edit a person with new values same as existing values -> edited */ command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND + TAG_DESC_HUSBAND; + + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_FRIEND + TAG_DESC_HUSBAND; assertCommandSuccess(command, index, BOB); /* Case: edit some fields -> edited */ @@ -125,7 +130,7 @@ public void edit() throws Exception { index = INDEX_FIRST_PERSON; selectPerson(index); command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY - + ADDRESS_DESC_AMY + TAG_DESC_FRIEND; + + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; // this can be misleading: card selection actually remains unchanged but the // browser's url is updated to reflect the new person's name assertCommandSuccess(command, index, AMY, index); @@ -169,6 +174,10 @@ public void edit() throws Exception { assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_ADDRESS_DESC, Address.MESSAGE_ADDRESS_CONSTRAINTS); + /* Case: invalid weight -> rejected */ + assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_WEIGHT_DESC, + Weight.MESSAGE_WEIGHT_CONSTRAINTS); + /* Case: invalid tag -> rejected */ assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_TAG_DESC, Tag.MESSAGE_TAG_CONSTRAINTS); @@ -179,12 +188,12 @@ public void edit() throws Exception { index = INDEX_FIRST_PERSON; assertFalse(getModel().getFilteredPersonList().get(index.getZeroBased()).equals(BOB)); command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND + TAG_DESC_HUSBAND; + + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_FRIEND + TAG_DESC_HUSBAND; assertCommandFailure(command, EditCommand.MESSAGE_DUPLICATE_PERSON); /* Case: edit a person with new values same as another person's values but with different tags -> rejected */ command = EditCommand.COMMAND_WORD + " " + index.getOneBased() + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_HUSBAND; + + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND; assertCommandFailure(command, EditCommand.MESSAGE_DUPLICATE_PERSON); } From 541dfd76edf48d6c9b3bccb51211466cb75d84b9 Mon Sep 17 00:00:00 2001 From: wayneong95 Date: Wed, 14 Mar 2018 16:10:43 +0800 Subject: [PATCH 021/227] Editted the add and edit commands to fit the new weight attribute --- .../seedu/address/logic/commands/AddCommand.java | 3 +++ .../address/logic/commands/EditCommand.java | 16 +++++++++++++--- .../address/logic/parser/AddCommandParser.java | 7 +++++-- .../address/logic/parser/EditCommandParser.java | 4 +++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index c334710c0ea3..ecf0bf31582e 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -6,6 +6,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.PREFIX_WEIGHT; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.person.Person; @@ -24,12 +25,14 @@ public class AddCommand extends UndoableCommand { + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " + PREFIX_ADDRESS + "ADDRESS " + + PREFIX_WEIGHT + "WEIGHT " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " + PREFIX_PHONE + "98765432 " + PREFIX_EMAIL + "johnd@example.com " + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " + + PREFIX_WEIGHT + "55.5 " + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index e6c3a3e034bc..0966e1d9f15b 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -6,6 +6,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.PREFIX_WEIGHT; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; import java.util.Collections; @@ -24,6 +25,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.person.exceptions.PersonNotFoundException; import seedu.address.model.tag.Tag; @@ -43,7 +45,7 @@ public class EditCommand extends UndoableCommand { + "[" + PREFIX_PHONE + "PHONE] " + "[" + PREFIX_EMAIL + "EMAIL] " + "[" + PREFIX_ADDRESS + "ADDRESS] " - + "[" + PREFIX_TAG + "TAG]...\n" + + "[" + PREFIX_WEIGHT + "WEIGHT] " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " 1 " + PREFIX_PHONE + "91234567 " + PREFIX_EMAIL + "johndoe@example.com"; @@ -106,9 +108,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()); + Weight updatedWeight = editPersonDescriptor.getWeight().orElse(personToEdit.getWeight()); Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); + return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedWeight, updatedTags); } @Override @@ -139,6 +142,7 @@ public static class EditPersonDescriptor { private Phone phone; private Email email; private Address address; + private Weight weight; private Set tags; public EditPersonDescriptor() {} @@ -152,6 +156,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setPhone(toCopy.phone); setEmail(toCopy.email); setAddress(toCopy.address); + setWeight(toCopy.weight); setTags(toCopy.tags); } @@ -159,7 +164,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(this.name, this.phone, this.email, this.address, this.tags); + return CollectionUtil.isAnyNonNull(this.name, this.phone, this.email, this.address, this.weight, this.tags); } public void setName(Name name) { @@ -194,6 +199,10 @@ public Optional
getAddress() { return Optional.ofNullable(address); } + public void setWeight(Weight weight) { this.weight = weight;} + + public Optional getWeight() { return Optional.ofNullable(weight);} + /** * Sets {@code tags} to this object's {@code tags}. * A defensive copy of {@code tags} is used internally. @@ -230,6 +239,7 @@ public boolean equals(Object other) { && getPhone().equals(e.getPhone()) && getEmail().equals(e.getEmail()) && getAddress().equals(e.getAddress()) + && getWeight().equals(e.getWeight()) && getTags().equals(e.getTags()); } } diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 3c729b388554..9a7e2a38a39b 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_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.PREFIX_WEIGHT; import java.util.Set; import java.util.stream.Stream; @@ -18,6 +19,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.tag.Tag; /** @@ -32,7 +34,7 @@ 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_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_WEIGHT, PREFIX_TAG); if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) || !argMultimap.getPreamble().isEmpty()) { @@ -44,9 +46,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(); + Weight weight = ParserUtil.parseWeight(argMultimap.getValue(PREFIX_WEIGHT)).get(); 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, weight, tagList); return new AddCommand(person); } catch (IllegalValueException ive) { diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index c9cdbed26cf1..21994d107a94 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -7,6 +7,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.PREFIX_WEIGHT; import java.util.Collection; import java.util.Collections; @@ -33,7 +34,7 @@ public class EditCommandParser implements Parser { public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_WEIGHT, PREFIX_TAG); Index index; @@ -49,6 +50,7 @@ public EditCommand parse(String args) throws ParseException { ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE)).ifPresent(editPersonDescriptor::setPhone); ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL)).ifPresent(editPersonDescriptor::setEmail); ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS)).ifPresent(editPersonDescriptor::setAddress); + ParserUtil.parseWeight(argMultimap.getValue(PREFIX_WEIGHT)).ifPresent(editPersonDescriptor::setWeight); parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags); } catch (IllegalValueException ive) { throw new ParseException(ive.getMessage(), ive); From 928d54ca0b1b446919800230fff3e0ef8b86bccb Mon Sep 17 00:00:00 2001 From: wayneong95 Date: Wed, 14 Mar 2018 16:11:04 +0800 Subject: [PATCH 022/227] no message --- .../seedu/address/logic/parser/CliSyntax.java | 1 + .../address/logic/parser/ParserUtil.java | 25 +++++++++++++++++++ .../java/seedu/address/model/AddressBook.java | 2 +- .../address/model/util/SampleDataUtil.java | 13 +++++----- .../address/storage/XmlAdaptedPerson.java | 18 +++++++++++-- .../java/seedu/address/ui/PersonCard.java | 3 +++ src/main/resources/view/PersonListCard.fxml | 13 +++++++--- .../testutil/EditPersonDescriptorBuilder.java | 10 ++++++++ .../seedu/address/testutil/PersonBuilder.java | 15 ++++++++++- .../seedu/address/testutil/PersonUtil.java | 2 ++ .../address/testutil/TypicalPersons.java | 24 ++++++++++-------- 11 files changed, 101 insertions(+), 25 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 75b1a9bf1190..ea63b85bd80b 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -10,6 +10,7 @@ public class CliSyntax { public static final Prefix PREFIX_PHONE = new Prefix("p/"); public static final Prefix PREFIX_EMAIL = new Prefix("e/"); public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); + public static final Prefix PREFIX_WEIGHT = new Prefix("w/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 5d6d4ae3f7b1..afa338d1e0b5 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -14,6 +14,7 @@ import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.tag.Tag; /** @@ -91,6 +92,30 @@ public static Optional parsePhone(Optional phone) throws IllegalV return phone.isPresent() ? Optional.of(parsePhone(phone.get())) : Optional.empty(); } + /** + * Parses a {@code String weight} into a {@code Weight}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws IllegalValueException if the given {@code weight} is invalid. + */ + public static Weight parseWeight(String weight) throws IllegalValueException { + requireNonNull(weight); + String trimmedWeight = weight.trim(); + if (!Weight.isValidWeight(trimmedWeight)) { + throw new IllegalValueException(Weight.MESSAGE_WEIGHT_CONSTRAINTS); + } + return new Weight(trimmedWeight); + } + + /** + * Parses a {@code Optional weight} into an {@code Optional} if {@code weight} is present. + * See header comment of this class regarding the use of {@code Optional} parameters. + */ + public static Optional parseWeight(Optional weight) throws IllegalValueException { + requireNonNull(weight); + return weight.isPresent() ? Optional.of(parseWeight(weight.get())) : Optional.empty(); + } + /** * Parses a {@code String address} into an {@code Address}. * Leading and trailing whitespaces will be trimmed. diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index f8d0260de159..8fd3d17ef90b 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -132,7 +132,7 @@ private Person syncWithMasterTagList(Person person) { final Set correctTagReferences = new HashSet<>(); personTags.forEach(tag -> correctTagReferences.add(masterTagObjects.get(tag))); return new Person( - person.getName(), person.getPhone(), person.getEmail(), person.getAddress(), correctTagReferences); + person.getName(), person.getPhone(), person.getEmail(), person.getAddress(), person.getWeight(), correctTagReferences); } /** diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index aea96bfb31f3..cdd6fdf9634f 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -10,6 +10,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.tag.Tag; @@ -20,22 +21,22 @@ 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 Address("Blk 30 Geylang Street 29, #06-40"), + new Address("Blk 30 Geylang Street 29, #06-40"), new Weight("55.5"), 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"), new Weight("55.5"), 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"), new Weight("55.5"), 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"), new Weight("55.5"), 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"), new Weight("55.5"), 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"), new Weight("55.5"), getTagSet("colleagues")) }; } diff --git a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java index 2cd92dc4fd20..713f1d140bac 100644 --- a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java @@ -14,6 +14,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.tag.Tag; /** @@ -31,6 +32,8 @@ public class XmlAdaptedPerson { private String email; @XmlElement(required = true) private String address; + @XmlElement(required = true) + private String weight; @XmlElement private List tagged = new ArrayList<>(); @@ -44,11 +47,12 @@ public XmlAdaptedPerson() {} /** * Constructs an {@code XmlAdaptedPerson} with the given person details. */ - public XmlAdaptedPerson(String name, String phone, String email, String address, List tagged) { + public XmlAdaptedPerson(String name, String phone, String email, String address, String weight, List tagged) { this.name = name; this.phone = phone; this.email = email; this.address = address; + this.weight = weight; if (tagged != null) { this.tagged = new ArrayList<>(tagged); } @@ -64,6 +68,7 @@ public XmlAdaptedPerson(Person source) { phone = source.getPhone().value; email = source.getEmail().value; address = source.getAddress().value; + weight = source.getWeight().value; tagged = new ArrayList<>(); for (Tag tag : source.getTags()) { tagged.add(new XmlAdaptedTag(tag)); @@ -113,8 +118,16 @@ public Person toModelType() throws IllegalValueException { } final Address address = new Address(this.address); + if (this.weight == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Weight.class.getSimpleName())); + } + if (!Weight.isValidWeight(this.weight)) { + throw new IllegalValueException(Weight.MESSAGE_WEIGHT_CONSTRAINTS); + } + final Weight weight = new Weight(this.weight); + final Set tags = new HashSet<>(personTags); - return new Person(name, phone, email, address, tags); + return new Person(name, phone, email, address, weight, tags); } @Override @@ -132,6 +145,7 @@ public boolean equals(Object other) { && Objects.equals(phone, otherPerson.phone) && Objects.equals(email, otherPerson.email) && Objects.equals(address, otherPerson.address) + && Objects.equals(weight, otherPerson.weight) && tagged.equals(otherPerson.tagged); } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index f6727ea83abd..ccbde2ad63f2 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -37,6 +37,8 @@ public class PersonCard extends UiPart { @FXML private Label email; @FXML + private Label weight; + @FXML private FlowPane tags; public PersonCard(Person person, int displayedIndex) { @@ -47,6 +49,7 @@ public PersonCard(Person person, int displayedIndex) { phone.setText(person.getPhone().value); address.setText(person.getAddress().value); email.setText(person.getEmail().value); + weight.setText(person.getWeight().value); person.getTags().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 f08ea32ad558..a7cb901fc9b1 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -7,30 +7,35 @@ + - + - + - + - + + + diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index 4584bd5044e1..fb6d0110cca8 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -10,6 +10,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.tag.Tag; /** @@ -36,6 +37,7 @@ public EditPersonDescriptorBuilder(Person person) { descriptor.setPhone(person.getPhone()); descriptor.setEmail(person.getEmail()); descriptor.setAddress(person.getAddress()); + descriptor.setWeight(person.getWeight()); descriptor.setTags(person.getTags()); } @@ -55,6 +57,14 @@ public EditPersonDescriptorBuilder withPhone(String phone) { return this; } + /** + * Sets the {@code Weight} of the {@code EditPersonDescriptor} that we are building. + */ + public EditPersonDescriptorBuilder withWeight(String weight) { + descriptor.setWeight(new Weight(weight)); + return this; + } + /** * Sets the {@code Email} of the {@code EditPersonDescriptor} that we are building. */ diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java index b124fc1d73b1..54f02efee4c0 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/PersonBuilder.java @@ -8,6 +8,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.tag.Tag; import seedu.address.model.util.SampleDataUtil; @@ -20,12 +21,14 @@ public class PersonBuilder { public static final String DEFAULT_PHONE = "85355255"; public static final String DEFAULT_EMAIL = "alice@gmail.com"; public static final String DEFAULT_ADDRESS = "123, Jurong West Ave 6, #08-111"; + public static final String DEFAULT_WEIGHT = "55.5"; public static final String DEFAULT_TAGS = "friends"; private Name name; private Phone phone; private Email email; private Address address; + private Weight weight; private Set tags; public PersonBuilder() { @@ -33,6 +36,7 @@ public PersonBuilder() { phone = new Phone(DEFAULT_PHONE); email = new Email(DEFAULT_EMAIL); address = new Address(DEFAULT_ADDRESS); + weight = new Weight(DEFAULT_WEIGHT); tags = SampleDataUtil.getTagSet(DEFAULT_TAGS); } @@ -44,6 +48,7 @@ public PersonBuilder(Person personToCopy) { phone = personToCopy.getPhone(); email = personToCopy.getEmail(); address = personToCopy.getAddress(); + weight = personToCopy.getWeight(); tags = new HashSet<>(personToCopy.getTags()); } @@ -87,8 +92,16 @@ public PersonBuilder withEmail(String email) { return this; } + /** + * Sets the {@code Weight} of the {@code Person} that we are building. + */ + public PersonBuilder withWeight(String weight) { + this.weight = new Weight(weight); + return this; + } + public Person build() { - return new Person(name, phone, email, address, tags); + return new Person(name, phone, email, address, weight, tags); } } diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index 642d4f174514..cad1116cd7c8 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -5,6 +5,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.PREFIX_WEIGHT; import seedu.address.logic.commands.AddCommand; import seedu.address.model.person.Person; @@ -30,6 +31,7 @@ public static String getPersonDetails(Person person) { sb.append(PREFIX_PHONE + person.getPhone().value + " "); sb.append(PREFIX_EMAIL + person.getEmail().value + " "); sb.append(PREFIX_ADDRESS + person.getAddress().value + " "); + sb.append(PREFIX_WEIGHT + person.getWeight().value + " "); person.getTags().stream().forEach( s -> sb.append(PREFIX_TAG + s.tagName + " ") ); diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index 6d7bdbfc55ed..8e989fa1000c 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -10,6 +10,8 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_WEIGHT_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_WEIGHT_BOB; import java.util.ArrayList; import java.util.Arrays; @@ -26,34 +28,34 @@ public class TypicalPersons { public static final Person ALICE = new PersonBuilder().withName("Alice Pauline") .withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com") - .withPhone("85355255") + .withPhone("85355255").withWeight("55.5") .withTags("friends").build(); public static final Person BENSON = new PersonBuilder().withName("Benson Meier") .withAddress("311, Clementi Ave 2, #02-25") - .withEmail("johnd@example.com").withPhone("98765432") + .withEmail("johnd@example.com").withPhone("98765432").withWeight("55.5") .withTags("owesMoney", "friends").build(); public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") - .withEmail("heinz@example.com").withAddress("wall street").build(); + .withEmail("heinz@example.com").withAddress("wall street").withWeight("55.5").build(); public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") - .withEmail("cornelia@example.com").withAddress("10th street").build(); + .withEmail("cornelia@example.com").withAddress("10th street").withWeight("55.5").build(); public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") - .withEmail("werner@example.com").withAddress("michegan ave").build(); + .withEmail("werner@example.com").withAddress("michegan ave").withWeight("55.5").build(); public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") - .withEmail("lydia@example.com").withAddress("little tokyo").build(); + .withEmail("lydia@example.com").withAddress("little tokyo").withWeight("55.5").build(); public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") - .withEmail("anna@example.com").withAddress("4th street").build(); + .withEmail("anna@example.com").withAddress("4th street").withWeight("55.5").build(); // Manually added public static final Person HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") - .withEmail("stefan@example.com").withAddress("little india").build(); + .withEmail("stefan@example.com").withAddress("little india").withWeight("55.5").build(); public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") - .withEmail("hans@example.com").withAddress("chicago ave").build(); + .withEmail("hans@example.com").withAddress("chicago ave").withWeight("55.5").build(); // Manually added - Person's details found in {@code CommandTestUtil} public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) - .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); + .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY).withTags(VALID_TAG_FRIEND).build(); public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER From a66e24d94331ad608080ac6df729b34ffe6e6075 Mon Sep 17 00:00:00 2001 From: wayneong95 Date: Wed, 14 Mar 2018 16:11:20 +0800 Subject: [PATCH 023/227] Updated the user guide --- docs/UserGuide.adoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 74248917e438..82e344b98c69 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -38,7 +38,7 @@ e.g. typing *`help`* and pressing kbd:[Enter] will open the help window. . Some example commands you can try: * *`list`* : lists all contacts -* **`add`**`n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` : adds a contact named `John Doe` to the Address Book. +* **`add`**`n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` w/55.5 : adds a contact named `John Doe` to the Address Book. * **`delete`**`3` : deletes the 3rd contact shown in the current list * *`exit`* : exits the app @@ -63,15 +63,15 @@ Format: `help` === Adding a person: `add` Adds a person to the address book + -Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]...` +Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS w/WEIGHT [t/TAG]...` [TIP] A person can have any number of tags (including 0) Examples: -* `add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` -* `add n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 t/criminal` +* `add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` w/55.5 +* `add n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 w/66.7 t/criminal` === Listing all persons : `list` From 68c561d392a86338ff03a941fb24a60ccb57ab3f Mon Sep 17 00:00:00 2001 From: Wenhao Cheng Date: Wed, 14 Mar 2018 16:30:18 +0800 Subject: [PATCH 024/227] Fixed case-insensitive Address field when adding person --- src/main/java/seedu/address/model/person/Address.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java index 91528d6080b3..1335b5897ba7 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/person/Address.java @@ -44,7 +44,7 @@ public static boolean isValidAddress(String test) { public boolean alphabeticallyEquals(Object other) { return other == this // short circuit if same object || (other instanceof Address // instanceof handles nulls - && this.value.toLowerCase().equals(((Address) other).value)); // state check + && this.value.toLowerCase().equals(((Address) other).value.toLowerCase())); // state check } @Override From a7b866f814e78875f0fb8791dd41a09d561c1df2 Mon Sep 17 00:00:00 2001 From: wayneong95 Date: Wed, 14 Mar 2018 16:39:21 +0800 Subject: [PATCH 025/227] Edited to fix the errors --- src/main/java/seedu/address/logic/commands/EditCommand.java | 4 ++-- .../java/seedu/address/logic/parser/AddCommandParser.java | 3 ++- .../java/seedu/address/logic/parser/EditCommandParser.java | 3 ++- src/main/java/seedu/address/model/AddressBook.java | 3 ++- src/main/java/seedu/address/storage/XmlAdaptedPerson.java | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 0966e1d9f15b..1e603b41e187 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -199,9 +199,9 @@ public Optional
getAddress() { return Optional.ofNullable(address); } - public void setWeight(Weight weight) { this.weight = weight;} + public void setWeight(Weight weight) { this.weight = weight; } - public Optional getWeight() { return Optional.ofNullable(weight);} + public Optional getWeight() { return Optional.ofNullable(weight); } /** * Sets {@code tags} to this object's {@code tags}. diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 9a7e2a38a39b..9dc170bf2e94 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -34,7 +34,8 @@ 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_WEIGHT, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + PREFIX_ADDRESS, PREFIX_WEIGHT, PREFIX_TAG); if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) || !argMultimap.getPreamble().isEmpty()) { diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index 21994d107a94..ce279effc6c6 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -34,7 +34,8 @@ public class EditCommandParser implements Parser { public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_WEIGHT, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + PREFIX_ADDRESS, PREFIX_WEIGHT, PREFIX_TAG); Index index; diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index 8fd3d17ef90b..692a863d8466 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -132,7 +132,8 @@ private Person syncWithMasterTagList(Person person) { final Set correctTagReferences = new HashSet<>(); personTags.forEach(tag -> correctTagReferences.add(masterTagObjects.get(tag))); return new Person( - person.getName(), person.getPhone(), person.getEmail(), person.getAddress(), person.getWeight(), correctTagReferences); + person.getName(), person.getPhone(), person.getEmail(), person.getAddress(), + person.getWeight(), correctTagReferences); } /** diff --git a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java index 713f1d140bac..2c76ea1c4fb9 100644 --- a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java @@ -47,7 +47,8 @@ public XmlAdaptedPerson() {} /** * Constructs an {@code XmlAdaptedPerson} with the given person details. */ - public XmlAdaptedPerson(String name, String phone, String email, String address, String weight, List tagged) { + public XmlAdaptedPerson(String name, String phone, String email, String address, + String weight, List tagged) { this.name = name; this.phone = phone; this.email = email; From 657e17a399fad491619b51067ba7d2f073af56ea Mon Sep 17 00:00:00 2001 From: wayneong95 Date: Wed, 14 Mar 2018 17:18:28 +0800 Subject: [PATCH 026/227] Edited errors 2.0 --- .../logic/commands/CommandTestUtil.java | 6 +- .../logic/parser/AddCommandParserTest.java | 54 ++++++++++++------ .../logic/parser/EditCommandParserTest.java | 3 +- .../address/model/person/WeightTest.java | 7 ++- .../address/storage/XmlAdaptedPersonTest.java | 15 +++-- .../address/testutil/TypicalPersons.java | 6 +- .../systemtests/AddCommandSystemTest.java | 57 ++++++++++++------- .../systemtests/EditCommandSystemTest.java | 24 +++++--- 8 files changed, 114 insertions(+), 58 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index d53a77028d6f..b1dcd00d894c 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -71,10 +71,12 @@ public class CommandTestUtil { static { DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) - .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY) + .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) + .withWeight(VALID_WEIGHT_AMY) .withTags(VALID_TAG_FRIEND).build(); DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) - .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB) + .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) + .withWeight(VALID_WEIGHT_BOB) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); } diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index b32a64b875de..536149862a7f 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -54,7 +54,8 @@ public class AddCommandParserTest { @Test public void parse_allFieldsPresent_success() { Person expectedPerson = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB).withTags(VALID_TAG_FRIEND).build(); + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB) + .withTags(VALID_TAG_FRIEND).build(); // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB @@ -80,7 +81,8 @@ public void parse_allFieldsPresent_success() { Person expectedPersonMultipleTags = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB) .withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND).build(); - assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, new AddCommand(expectedPersonMultipleTags)); } @@ -88,8 +90,10 @@ public void parse_allFieldsPresent_success() { public void parse_optionalFieldsMissing_success() { // zero tags Person expectedPerson = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) - .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY).withTags().build(); - assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY, + .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY) + .withTags().build(); + assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + + WEIGHT_DESC_AMY, new AddCommand(expectedPerson)); } @@ -98,62 +102,76 @@ public void parse_compulsoryFieldMissing_failure() { String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE); // missing name prefix - assertParseFailure(parser, VALID_NAME_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB, + assertParseFailure(parser, VALID_NAME_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + WEIGHT_DESC_BOB, expectedMessage); // missing phone prefix - assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB, + assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + WEIGHT_DESC_BOB, expectedMessage); // missing email prefix - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB, + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB + ADDRESS_DESC_BOB + + WEIGHT_DESC_BOB, expectedMessage); // missing address prefix - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + VALID_ADDRESS_BOB + WEIGHT_DESC_BOB, + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + VALID_ADDRESS_BOB + + WEIGHT_DESC_BOB, expectedMessage); // missing weight prefix - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + VALID_WEIGHT_BOB, + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + VALID_WEIGHT_BOB, expectedMessage); // all prefixes missing - assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB + VALID_ADDRESS_BOB + VALID_WEIGHT_BOB, + assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB + VALID_ADDRESS_BOB + + VALID_WEIGHT_BOB, expectedMessage); } @Test public void parse_invalidValue_failure() { // invalid name - assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Name.MESSAGE_NAME_CONSTRAINTS); // invalid phone - assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Phone.MESSAGE_PHONE_CONSTRAINTS); // invalid email - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB + + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Email.MESSAGE_EMAIL_CONSTRAINTS); // invalid address - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC + WEIGHT_DESC_BOB + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC + + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_ADDRESS_CONSTRAINTS); // invalid weight - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + INVALID_WEIGHT_DESC + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + INVALID_WEIGHT_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Weight.MESSAGE_WEIGHT_CONSTRAINTS); // invalid tag - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + WEIGHT_DESC_BOB + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + WEIGHT_DESC_BOB + INVALID_TAG_DESC + VALID_TAG_FRIEND, Tag.MESSAGE_TAG_CONSTRAINTS); // two invalid values, only first invalid value reported - assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC + WEIGHT_DESC_BOB, + assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC + + WEIGHT_DESC_BOB, Name.MESSAGE_NAME_CONSTRAINTS); // non-empty preamble - assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + WEIGHT_DESC_BOB + assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + + WEIGHT_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index b4a17daf095a..d2b0f0747454 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -117,7 +117,8 @@ public void parse_allFieldsSpecified_success() { + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY + NAME_DESC_AMY + TAG_DESC_FRIEND; EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) - .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY) + .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) + .withWeight(VALID_WEIGHT_AMY) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); diff --git a/src/test/java/seedu/address/model/person/WeightTest.java b/src/test/java/seedu/address/model/person/WeightTest.java index 0465002ada90..54a3ebdaa3af 100644 --- a/src/test/java/seedu/address/model/person/WeightTest.java +++ b/src/test/java/seedu/address/model/person/WeightTest.java @@ -1,10 +1,13 @@ package seedu.address.model.person; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; + import seedu.address.testutil.Assert; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; + public class WeightTest { diff --git a/src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java b/src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java index 5cb99b3573f0..3adfbc137dc8 100644 --- a/src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/XmlAdaptedPersonTest.java @@ -51,7 +51,8 @@ public void toModelType_invalidName_throwsIllegalValueException() { @Test public void toModelType_nullName_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); + XmlAdaptedPerson person = new XmlAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, + VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -66,7 +67,8 @@ public void toModelType_invalidPhone_throwsIllegalValueException() { @Test public void toModelType_nullPhone_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); + XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, null, VALID_EMAIL, + VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -81,7 +83,8 @@ public void toModelType_invalidEmail_throwsIllegalValueException() { @Test public void toModelType_nullEmail_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); + XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, null, + VALID_ADDRESS, VALID_WEIGHT, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -96,7 +99,8 @@ public void toModelType_invalidAddress_throwsIllegalValueException() { @Test public void toModelType_nullAddress_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_WEIGHT, VALID_TAGS); + XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, + null, VALID_WEIGHT, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -111,7 +115,8 @@ public void toModelType_invalidWeight_throwsIllegalValueException() { @Test public void toModelType_nullWeight_throwsIllegalValueException() { - XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, null, VALID_TAGS); + XmlAdaptedPerson person = new XmlAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, + VALID_ADDRESS, null, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Weight.class.getSimpleName()); Assert.assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index 8e989fa1000c..68c71d0e7b1c 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -53,9 +53,11 @@ public class TypicalPersons { // Manually added - Person's details found in {@code CommandTestUtil} public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) - .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY).withTags(VALID_TAG_FRIEND).build(); + .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY) + .withTags(VALID_TAG_FRIEND).build(); public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB) + .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER diff --git a/src/test/java/systemtests/AddCommandSystemTest.java b/src/test/java/systemtests/AddCommandSystemTest.java index 68ad4851af58..dec2e6e6ef1e 100644 --- a/src/test/java/systemtests/AddCommandSystemTest.java +++ b/src/test/java/systemtests/AddCommandSystemTest.java @@ -3,16 +3,14 @@ import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_WEIGHT_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_TAG_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_WEIGHT_DESC; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY; @@ -27,9 +25,11 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_WEIGHT_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_WEIGHT_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; +import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.WEIGHT_DESC_BOB; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.testutil.TypicalPersons.ALICE; import static seedu.address.testutil.TypicalPersons.AMY; @@ -52,6 +52,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Weight; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.tag.Tag; import seedu.address.testutil.PersonBuilder; @@ -87,29 +88,36 @@ public void add() throws Exception { /* Case: add a person with all fields same as another person in the address book except name -> added */ toAdd = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) .withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY).withTags(VALID_TAG_FRIEND).build(); - command = AddCommand.COMMAND_WORD + NAME_DESC_BOB + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY - + TAG_DESC_FRIEND; + command = AddCommand.COMMAND_WORD + NAME_DESC_BOB + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); /* Case: add a person with all fields same as another person in the address book except phone -> added */ toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY) .withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY).withTags(VALID_TAG_FRIEND).build(); - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY - + TAG_DESC_FRIEND; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; + assertCommandSuccess(command, toAdd); + + /* Case: add a person with all fields same as another person in the address book except weight -> added */ + toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) + .withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_BOB).withTags(VALID_TAG_FRIEND).build(); + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); /* Case: add a person with all fields same as another person in the address book except email -> added */ toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_BOB) .withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_AMY).withTags(VALID_TAG_FRIEND).build(); - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_BOB + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY - + TAG_DESC_FRIEND; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_BOB + + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); /* Case: add a person with all fields same as another person in the address book except address -> added */ toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) .withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_AMY).withTags(VALID_TAG_FRIEND).build(); - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_BOB + WEIGHT_DESC_AMY - + TAG_DESC_FRIEND; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + + ADDRESS_DESC_BOB + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); /* Case: add to empty address book -> added */ @@ -118,8 +126,8 @@ public void add() throws Exception { /* Case: add a person with tags, command with parameters in random order -> added */ toAdd = BOB; - command = AddCommand.COMMAND_WORD + TAG_DESC_FRIEND + PHONE_DESC_BOB + ADDRESS_DESC_BOB + NAME_DESC_BOB + WEIGHT_DESC_BOB - + TAG_DESC_HUSBAND + EMAIL_DESC_BOB; + command = AddCommand.COMMAND_WORD + TAG_DESC_FRIEND + PHONE_DESC_BOB + ADDRESS_DESC_BOB + + NAME_DESC_BOB + WEIGHT_DESC_BOB + TAG_DESC_HUSBAND + EMAIL_DESC_BOB; assertCommandSuccess(command, toAdd); /* Case: add a person, missing tags -> added */ @@ -171,24 +179,33 @@ public void add() throws Exception { assertCommandFailure(command, Messages.MESSAGE_UNKNOWN_COMMAND); /* Case: invalid name -> rejected */ - command = AddCommand.COMMAND_WORD + INVALID_NAME_DESC + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; + command = AddCommand.COMMAND_WORD + INVALID_NAME_DESC + PHONE_DESC_AMY + EMAIL_DESC_AMY + + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; assertCommandFailure(command, Name.MESSAGE_NAME_CONSTRAINTS); /* Case: invalid phone -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + INVALID_PHONE_DESC + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + INVALID_PHONE_DESC + EMAIL_DESC_AMY + + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; assertCommandFailure(command, Phone.MESSAGE_PHONE_CONSTRAINTS); + /* Case: invalid weight -> rejected */ + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + + ADDRESS_DESC_AMY + INVALID_WEIGHT_DESC; + assertCommandFailure(command, Weight.MESSAGE_WEIGHT_CONSTRAINTS); + /* Case: invalid email -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + INVALID_EMAIL_DESC + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + INVALID_EMAIL_DESC + + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY; assertCommandFailure(command, Email.MESSAGE_EMAIL_CONSTRAINTS); /* Case: invalid address -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + INVALID_ADDRESS_DESC + WEIGHT_DESC_AMY; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + INVALID_ADDRESS_DESC + + WEIGHT_DESC_AMY; assertCommandFailure(command, Address.MESSAGE_ADDRESS_CONSTRAINTS); /* Case: invalid tag -> rejected */ - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + WEIGHT_DESC_AMY - + INVALID_TAG_DESC; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + + WEIGHT_DESC_AMY + INVALID_TAG_DESC; assertCommandFailure(command, Tag.MESSAGE_TAG_CONSTRAINTS); } diff --git a/src/test/java/systemtests/EditCommandSystemTest.java b/src/test/java/systemtests/EditCommandSystemTest.java index a7a5f71b3dfb..cf6f5ee53e1c 100644 --- a/src/test/java/systemtests/EditCommandSystemTest.java +++ b/src/test/java/systemtests/EditCommandSystemTest.java @@ -67,9 +67,11 @@ public void edit() throws Exception { */ Index index = INDEX_FIRST_PERSON; String command = " " + EditCommand.COMMAND_WORD + " " + index.getOneBased() + " " + NAME_DESC_BOB + " " - + PHONE_DESC_BOB + " " + EMAIL_DESC_BOB + " " + ADDRESS_DESC_BOB + " " + WEIGHT_DESC_BOB + " " + TAG_DESC_HUSBAND + " "; + + PHONE_DESC_BOB + " " + EMAIL_DESC_BOB + " " + ADDRESS_DESC_BOB + " " + WEIGHT_DESC_BOB + + " " + TAG_DESC_HUSBAND + " "; Person editedPerson = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB).withTags(VALID_TAG_HUSBAND).build(); + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withWeight(VALID_WEIGHT_BOB) + .withTags(VALID_TAG_HUSBAND).build(); assertCommandSuccess(command, index, editedPerson); /* Case: undo editing the last person in the list -> last person restored */ @@ -159,27 +161,33 @@ public void edit() throws Exception { EditCommand.MESSAGE_NOT_EDITED); /* Case: invalid name -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_NAME_DESC, + assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + + INVALID_NAME_DESC, Name.MESSAGE_NAME_CONSTRAINTS); /* Case: invalid phone -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_PHONE_DESC, + assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + + INVALID_PHONE_DESC, Phone.MESSAGE_PHONE_CONSTRAINTS); /* Case: invalid email -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_EMAIL_DESC, + assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + + INVALID_EMAIL_DESC, Email.MESSAGE_EMAIL_CONSTRAINTS); /* Case: invalid address -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_ADDRESS_DESC, + assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + + INVALID_ADDRESS_DESC, Address.MESSAGE_ADDRESS_CONSTRAINTS); /* Case: invalid weight -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_WEIGHT_DESC, + assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + + INVALID_WEIGHT_DESC, Weight.MESSAGE_WEIGHT_CONSTRAINTS); /* Case: invalid tag -> rejected */ - assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + INVALID_TAG_DESC, + assertCommandFailure(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + + INVALID_TAG_DESC, Tag.MESSAGE_TAG_CONSTRAINTS); /* Case: edit a person with new values same as another person's values -> rejected */ From c75e4b3a88715484db7022e71f3ce43d45071fa9 Mon Sep 17 00:00:00 2001 From: Wenhao Cheng Date: Wed, 14 Mar 2018 17:25:57 +0800 Subject: [PATCH 027/227] Fixed and updated Developer Guide from v1.0 --- docs/DeveloperGuide.adoc | 107 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 5 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 1733af113b29..99bd4d99625f 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -782,13 +782,22 @@ See this https://github.com/se-edu/addressbook-level4/pull/599[PR] for the step- *Target user profile*: -* has a need to manage a significant number of contacts +* has a need to manage a significant number of clients * prefer desktop apps over other types * can type fast * prefers typing over mouse input * is reasonably comfortable using CLI apps +* personal trainers who keep records of clients +* personal trainers who want to track clients' progress -*Value proposition*: manage contacts faster than a typical mouse/GUI driven app + + +*Value proposition*: + +* manage clients faster than a typical mouse/GUI driven app +* group clients according to BMI classification +* track individual client's progress using a chart for weight changes +* set goals for clients and see clients' feedback [appendix] == User Stories @@ -806,12 +815,18 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un |`* * *` |user |find a person by name |locate details of persons without having to go through the entire list +|`* * *` |user |update the weight of my client |track his/her weight progress + +|`* * *` |user |set goals for my clients |know what target we both are working towards + |`* *` |user |hide <> by default |minimize chance of someone else seeing them by accident -|`*` |user with many persons in the address book |sort persons by name |locate a person easily +|`* *` |user |track the weight changes of my clients |view my clients' progression till date using past weight updates + +|`* *` |user with many persons in the client tracker |sort persons by BMI classification |prioritise the needs of my clients and see which clients to focus on |======================================================================= -_{More to be added}_ + [appendix] == Use Cases @@ -844,7 +859,89 @@ Use case ends. + Use case resumes at step 2. -_{More to be added}_ + +=== Use case: Add person + +*MSS* + +1. User requests to add person +2. AddressBook prompts for data input +3. User inputs data for person to be added +4. AddressBook adds the new person ++ +Use case ends. + +*Extensions* + +[none] +* 3a. Person of the same name (regardless of case) is already in AddressBook ++ +[none] +** 3a1. AddressBook shows an error message. ++ +Use case resumes at step 2. + + +=== Use case: Add goal for person + +*MSS* + +1. User requests to add goal +2. AddressBook prompts for data input +3. User inputs person name and goal to be added +4. AddressBook adds the new goal for the person ++ +Use case ends. + +*Extensions* + +[none] +* 3a. The given index is invalid. ++ +[none] +** 3a1. AddressBook shows an error message. ++ +Use case resumes at step 2. + +[none] +* 3b. The input goal is empty. ++ +[none] +** 3b1. AddressBook shows an error message. ++ +Use case resumes at step 2. + + +=== Use case: Track weight changes for person + +*MSS* + +1. User requests to track weight changes +2. AddressBook prompts for data input +3. User inputs person to track past weight +4. AddressBook displays a chart showing past changes in weight ++ +Use case ends. + +*Extensions* + +[none] +* 3a. The given index is invalid. ++ +[none] +** 3a1. AddressBook shows an error message. ++ +Use case resumes at step 2. + +[none] +* 4a. There are no changes to track. ++ +[none] +** 4a1. AddressBook shows an error message. ++ +Use case resumes at step 2. + + [appendix] == Non Functional Requirements From 19e8b688a3a7c03fc21b090ea138145e5b2ec960 Mon Sep 17 00:00:00 2001 From: wayneong95 Date: Wed, 14 Mar 2018 19:02:02 +0800 Subject: [PATCH 028/227] Editted errors 3.0 --- .../seedu/address/logic/parser/AddCommandParser.java | 2 +- .../invalidPersonAddressBook.xml | 1 + .../typicalPersonsAddressBook.xml | 7 +++++++ src/test/data/XmlUtilTest/invalidPersonField.xml | 1 + src/test/data/XmlUtilTest/missingPersonField.xml | 1 + src/test/data/XmlUtilTest/validAddressBook.xml | 9 +++++++++ src/test/data/XmlUtilTest/validPerson.xml | 1 + src/test/java/guitests/GuiRobot.java | 2 +- .../seedu/address/logic/commands/CommandTestUtil.java | 2 +- src/test/java/systemtests/AddCommandSystemTest.java | 4 ++-- 10 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 9dc170bf2e94..b56976bca054 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -37,7 +37,7 @@ public AddCommand parse(String args) throws ParseException { ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_WEIGHT, PREFIX_TAG); - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_WEIGHT) || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } diff --git a/src/test/data/XmlSerializableAddressBookTest/invalidPersonAddressBook.xml b/src/test/data/XmlSerializableAddressBookTest/invalidPersonAddressBook.xml index 13d5b1cb1c8a..dd21862dad06 100644 --- a/src/test/data/XmlSerializableAddressBookTest/invalidPersonAddressBook.xml +++ b/src/test/data/XmlSerializableAddressBookTest/invalidPersonAddressBook.xml @@ -6,5 +6,6 @@ 9482424 hans@exam!32ple
4th street
+ 55.5 diff --git a/src/test/data/XmlSerializableAddressBookTest/typicalPersonsAddressBook.xml b/src/test/data/XmlSerializableAddressBookTest/typicalPersonsAddressBook.xml index c778cccc4c89..7d293f16b24e 100644 --- a/src/test/data/XmlSerializableAddressBookTest/typicalPersonsAddressBook.xml +++ b/src/test/data/XmlSerializableAddressBookTest/typicalPersonsAddressBook.xml @@ -7,6 +7,7 @@ 85355255 alice@example.com
123, Jurong West Ave 6, #08-111
+ 55.5 friends @@ -14,6 +15,7 @@ 98765432 johnd@example.com
311, Clementi Ave 2, #02-25
+ 55.5 owesMoney friends
@@ -22,30 +24,35 @@ 95352563 heinz@example.com
wall street
+ 55.5 Daniel Meier 87652533 cornelia@example.com
10th street
+ 55.5
Elle Meyer 9482224 werner@example.com
michegan ave
+ 55.5
Fiona Kunz 9482427 lydia@example.com
little tokyo
+ 55.5
George Best 9482442 anna@example.com
4th street
+ 55.5
friends owesMoney diff --git a/src/test/data/XmlUtilTest/invalidPersonField.xml b/src/test/data/XmlUtilTest/invalidPersonField.xml index ba49c971e884..9791c1d7f21a 100644 --- a/src/test/data/XmlUtilTest/invalidPersonField.xml +++ b/src/test/data/XmlUtilTest/invalidPersonField.xml @@ -5,5 +5,6 @@ 9482asf424 hans@example
4th street
+ 55.5 friends diff --git a/src/test/data/XmlUtilTest/missingPersonField.xml b/src/test/data/XmlUtilTest/missingPersonField.xml index c0da5c86d080..7a9992d31f72 100644 --- a/src/test/data/XmlUtilTest/missingPersonField.xml +++ b/src/test/data/XmlUtilTest/missingPersonField.xml @@ -4,5 +4,6 @@ 9482424 hans@example
4th street
+ 55.5 friends diff --git a/src/test/data/XmlUtilTest/validAddressBook.xml b/src/test/data/XmlUtilTest/validAddressBook.xml index 6265778674d3..e0fc1ea72252 100644 --- a/src/test/data/XmlUtilTest/validAddressBook.xml +++ b/src/test/data/XmlUtilTest/validAddressBook.xml @@ -5,53 +5,62 @@ 9482424 hans@example.com
4th street
+ 55.5 Ruth Mueller 87249245 ruth@example.com
81th street
+ 55.5
Heinz Kurz 95352563 heinz@example.com
wall street
+ 55.5
Cornelia Meier 87652533 cornelia@example.com
10th street
+ 55.5
Werner Meyer 9482224 werner@example.com
michegan ave
+ 55.5
Lydia Kunz 9482427 lydia@example.com
little tokyo
+ 55.5
Anna Best 9482442 anna@example.com
4th street
+ 55.5
Stefan Meier 8482424 stefan@example.com
little india
+ 55.5
Martin Mueller 8482131 hans@example.com
chicago ave
+ 55.5
diff --git a/src/test/data/XmlUtilTest/validPerson.xml b/src/test/data/XmlUtilTest/validPerson.xml index c029008d54f4..5ef9bcde8c88 100644 --- a/src/test/data/XmlUtilTest/validPerson.xml +++ b/src/test/data/XmlUtilTest/validPerson.xml @@ -4,5 +4,6 @@ 9482424 hans@example
4th street
+ 55.5 friends diff --git a/src/test/java/guitests/GuiRobot.java b/src/test/java/guitests/GuiRobot.java index 965e6ebed63c..265ec17ba5e4 100644 --- a/src/test/java/guitests/GuiRobot.java +++ b/src/test/java/guitests/GuiRobot.java @@ -15,7 +15,7 @@ public class GuiRobot extends FxRobot { private static final int PAUSE_FOR_HUMAN_DELAY_MILLISECONDS = 250; - private static final int DEFAULT_WAIT_FOR_EVENT_TIMEOUT_MILLISECONDS = 5000; + private static final int DEFAULT_WAIT_FOR_EVENT_TIMEOUT_MILLISECONDS = 50000; private static final String PROPERTY_TESTFX_HEADLESS = "testfx.headless"; diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index b1dcd00d894c..74c92a641154 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -39,7 +39,7 @@ public class CommandTestUtil { public static final String VALID_ADDRESS_AMY = "Block 312, Amy Street 1"; public static final String VALID_ADDRESS_BOB = "Block 123, Bobby Street 3"; public static final String VALID_WEIGHT_AMY = "55.5"; - public static final String VALID_WEIGHT_BOB = "55.5"; + public static final String VALID_WEIGHT_BOB = "65.5"; public static final String VALID_TAG_HUSBAND = "husband"; public static final String VALID_TAG_FRIEND = "friend"; diff --git a/src/test/java/systemtests/AddCommandSystemTest.java b/src/test/java/systemtests/AddCommandSystemTest.java index dec2e6e6ef1e..e74efb3b8c39 100644 --- a/src/test/java/systemtests/AddCommandSystemTest.java +++ b/src/test/java/systemtests/AddCommandSystemTest.java @@ -102,8 +102,8 @@ public void add() throws Exception { /* Case: add a person with all fields same as another person in the address book except weight -> added */ toAdd = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) .withAddress(VALID_ADDRESS_AMY).withWeight(VALID_WEIGHT_BOB).withTags(VALID_TAG_FRIEND).build(); - command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_AMY + ADDRESS_DESC_AMY - + WEIGHT_DESC_AMY + TAG_DESC_FRIEND; + command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + + WEIGHT_DESC_BOB + TAG_DESC_FRIEND; assertCommandSuccess(command, toAdd); /* Case: add a person with all fields same as another person in the address book except email -> added */ From 0acd170529fba789e3b68816687ba9ceef40e98d Mon Sep 17 00:00:00 2001 From: hypertun Date: Thu, 15 Mar 2018 20:39:18 +0800 Subject: [PATCH 029/227] Added Gender attribute --- docs/UserGuide.adoc | 8 +-- .../address/logic/commands/AddCommand.java | 3 + .../address/logic/commands/EditCommand.java | 19 ++++- .../logic/parser/AddCommandParser.java | 10 ++- .../seedu/address/logic/parser/CliSyntax.java | 1 + .../logic/parser/EditCommandParser.java | 4 +- .../address/logic/parser/ParserUtil.java | 25 +++++++ .../java/seedu/address/model/AddressBook.java | 2 +- .../seedu/address/model/person/Gender.java | 47 ++++++++++++ .../seedu/address/model/person/Person.java | 12 +++- .../address/model/util/SampleDataUtil.java | 13 ++-- .../address/storage/XmlAdaptedPerson.java | 19 ++++- .../java/seedu/address/ui/PersonCard.java | 3 + src/main/resources/view/PersonListCard.fxml | 3 +- .../invalidAndValidPersonAddressBook.xml | 4 ++ .../invalidPersonAddressBook.xml | 2 + .../invalidPersonAddressBook.xml | 1 + .../typicalPersonsAddressBook.xml | 7 ++ .../data/XmlUtilTest/invalidPersonField.xml | 1 + .../data/XmlUtilTest/missingPersonField.xml | 1 + .../data/XmlUtilTest/validAddressBook.xml | 9 +++ src/test/data/XmlUtilTest/validPerson.xml | 1 + .../guitests/guihandles/PersonCardHandle.java | 7 ++ .../address/commons/util/XmlUtilTest.java | 7 +- .../logic/commands/CommandTestUtil.java | 10 ++- .../commands/EditPersonDescriptorTest.java | 5 ++ .../logic/parser/AddCommandParserTest.java | 61 ++++++++++------ .../logic/parser/EditCommandParserTest.java | 14 +++- .../address/model/person/WeightTest.java | 2 +- .../address/storage/XmlAdaptedPersonTest.java | 50 ++++++++++--- .../testutil/EditPersonDescriptorBuilder.java | 9 +++ .../seedu/address/testutil/PersonBuilder.java | 15 +++- .../seedu/address/testutil/PersonUtil.java | 2 + .../address/testutil/TypicalPersons.java | 28 +++++--- .../address/ui/testutil/GuiTestAssert.java | 2 + .../systemtests/AddCommandSystemTest.java | 72 +++++++++++++------ .../systemtests/EditCommandSystemTest.java | 23 ++++-- 37 files changed, 403 insertions(+), 99 deletions(-) create mode 100644 src/main/java/seedu/address/model/person/Gender.java diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 82e344b98c69..c27cc6644b40 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -63,15 +63,15 @@ Format: `help` === Adding a person: `add` Adds a person to the address book + -Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS w/WEIGHT [t/TAG]...` +Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS w/WEIGHT g/GENDER [t/TAG]...` [TIP] A person can have any number of tags (including 0) Examples: -* `add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` w/55.5 -* `add n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 w/66.7 t/criminal` +* `add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` w/55.5 g/M +* `add n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 w/66.7 g/f t/criminal` === Listing all persons : `list` @@ -81,7 +81,7 @@ Format: `list` === Editing a person : `edit` Edits an existing person in the address book. + -Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]...` +Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [w/WEIGHT] [g/GENDER] [t/TAG]...` **** * Edits the person at the specified `INDEX`. The index refers to the index number shown in the last person listing. The index *must be a positive integer* 1, 2, 3, ... diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 7860e4cb2493..233b4e5141c9 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -3,6 +3,7 @@ import static java.util.Objects.requireNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -32,6 +33,7 @@ public class AddCommand extends UndoableCommand { + PREFIX_EMAIL + "EMAIL " + PREFIX_ADDRESS + "ADDRESS " + PREFIX_WEIGHT + "WEIGHT " + + PREFIX_GENDER + "GENDER " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " @@ -39,6 +41,7 @@ public class AddCommand extends UndoableCommand { + PREFIX_EMAIL + "johnd@example.com " + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " + PREFIX_WEIGHT + "55.5 " + + PREFIX_GENDER + "M " + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index da45cf779956..b7ba0eeb92ec 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -3,6 +3,7 @@ import static java.util.Objects.requireNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -22,6 +23,7 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Gender; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -50,7 +52,9 @@ public class EditCommand extends UndoableCommand { + "[" + PREFIX_PHONE + "PHONE] " + "[" + PREFIX_EMAIL + "EMAIL] " + "[" + PREFIX_ADDRESS + "ADDRESS] " - + "[" + PREFIX_WEIGHT + "WEIGHT] " + "[" + PREFIX_TAG + "TAG]...\n" + + "[" + PREFIX_WEIGHT + "WEIGHT] " + + "[" + PREFIX_GENDER + "GENDER] " + + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " 1 " + PREFIX_PHONE + "91234567 " + PREFIX_EMAIL + "johndoe@example.com"; @@ -114,9 +118,10 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); Weight updatedWeight = editPersonDescriptor.getWeight().orElse(personToEdit.getWeight()); + Gender updatedGender = editPersonDescriptor.getGender().orElse(personToEdit.getGender()); Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedWeight, updatedTags); + return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedWeight, updatedGender, updatedTags); } @Override @@ -148,6 +153,7 @@ public static class EditPersonDescriptor { private Email email; private Address address; private Weight weight; + private Gender gender; private Set tags; public EditPersonDescriptor() {} @@ -162,6 +168,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setEmail(toCopy.email); setAddress(toCopy.address); setWeight(toCopy.weight); + setGender(toCopy.gender); setTags(toCopy.tags); } @@ -169,7 +176,8 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(this.name, this.phone, this.email, this.address, this.weight, this.tags); + return CollectionUtil.isAnyNonNull(this.name, this.phone, this.email, this.address, this.weight, this.gender + , this.tags); } public void setName(Name name) { @@ -208,6 +216,10 @@ public Optional
getAddress() { public Optional getWeight() { return Optional.ofNullable(weight); } + public void setGender(Gender gender) { this.gender = gender; } + + public Optional getGender() { return Optional.ofNullable(gender); } + /** * Sets {@code tags} to this object's {@code tags}. * A defensive copy of {@code tags} is used internally. @@ -245,6 +257,7 @@ && getPhone().equals(e.getPhone()) && getEmail().equals(e.getEmail()) && getAddress().equals(e.getAddress()) && getWeight().equals(e.getWeight()) + && getGender().equals(e.getGender()) && getTags().equals(e.getTags()); } } diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index b56976bca054..399a7cb1d8bf 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -3,6 +3,7 @@ import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -16,6 +17,7 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Gender; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -35,9 +37,10 @@ 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_WEIGHT, PREFIX_TAG); + PREFIX_ADDRESS, PREFIX_WEIGHT, PREFIX_GENDER, PREFIX_TAG); - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_WEIGHT) + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_WEIGHT + , PREFIX_GENDER) || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } @@ -48,9 +51,10 @@ public AddCommand parse(String args) throws ParseException { Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL)).get(); Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS)).get(); Weight weight = ParserUtil.parseWeight(argMultimap.getValue(PREFIX_WEIGHT)).get(); + Gender gender = ParserUtil.parseGender(argMultimap.getValue(PREFIX_GENDER)).get(); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - Person person = new Person(name, phone, email, address, weight, tagList); + Person person = new Person(name, phone, email, address, weight, gender, tagList); return new AddCommand(person); } catch (IllegalValueException ive) { diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index ea63b85bd80b..bbceb833b3c5 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -11,6 +11,7 @@ public class CliSyntax { public static final Prefix PREFIX_EMAIL = new Prefix("e/"); public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); public static final Prefix PREFIX_WEIGHT = new Prefix("w/"); + public static final Prefix PREFIX_GENDER = new Prefix("g/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); } diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index ce279effc6c6..126a790c1a8a 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -4,6 +4,7 @@ import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -35,7 +36,7 @@ public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, - PREFIX_ADDRESS, PREFIX_WEIGHT, PREFIX_TAG); + PREFIX_ADDRESS, PREFIX_WEIGHT, PREFIX_GENDER, PREFIX_TAG); Index index; @@ -52,6 +53,7 @@ public EditCommand parse(String args) throws ParseException { ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL)).ifPresent(editPersonDescriptor::setEmail); ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS)).ifPresent(editPersonDescriptor::setAddress); ParserUtil.parseWeight(argMultimap.getValue(PREFIX_WEIGHT)).ifPresent(editPersonDescriptor::setWeight); + ParserUtil.parseGender(argMultimap.getValue(PREFIX_GENDER)).ifPresent(editPersonDescriptor::setGender); parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags); } catch (IllegalValueException ive) { throw new ParseException(ive.getMessage(), ive); diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index afa338d1e0b5..b8e3ea88bd0c 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -12,6 +12,7 @@ import seedu.address.commons.util.StringUtil; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Gender; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; import seedu.address.model.person.Weight; @@ -164,6 +165,30 @@ public static Optional parseEmail(Optional email) throws IllegalV return email.isPresent() ? Optional.of(parseEmail(email.get())) : Optional.empty(); } + /** + * Parses a {@code String Gender} into a {@code Gender}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws IllegalValueException if the given {@code gender} is invalid. + */ + public static Gender parseGender(String gender) throws IllegalValueException { + requireNonNull(gender); + String trimmedGender = gender.trim(); + if (!Gender.isValidGender(trimmedGender)) { + throw new IllegalValueException(Gender.MESSAGE_GENDER_CONSTRAINTS); + } + return new Gender(trimmedGender); + } + + /** + * Parses a {@code Optional gender} into an {@code Optional} if {@code gender} is present. + * See header comment of this class regarding the use of {@code Optional} parameters. + */ + public static Optional parseGender(Optional gender) throws IllegalValueException { + requireNonNull(gender); + return gender.isPresent() ? Optional.of(parseGender(gender.get())) : Optional.empty(); + } + /** * Parses a {@code String tag} into a {@code Tag}. * Leading and trailing whitespaces will be trimmed. diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index 692a863d8466..e47acc7da753 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -133,7 +133,7 @@ private Person syncWithMasterTagList(Person person) { personTags.forEach(tag -> correctTagReferences.add(masterTagObjects.get(tag))); return new Person( person.getName(), person.getPhone(), person.getEmail(), person.getAddress(), - person.getWeight(), correctTagReferences); + person.getWeight(), person.getGender(), correctTagReferences); } /** diff --git a/src/main/java/seedu/address/model/person/Gender.java b/src/main/java/seedu/address/model/person/Gender.java new file mode 100644 index 000000000000..5da26e1a7226 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Gender.java @@ -0,0 +1,47 @@ +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +public class Gender { + + public static final String MESSAGE_GENDER_CONSTRAINTS = + "Gender can only be the alphabets M or F or m or f"; + public static final String GENDER_VALIDATION_REGEX = "[mfMF]{1}+"; + public final String value; + + /** + * Constructs a {@code Gender}. + * + * @param sex A valid gender. + */ + public Gender(String sex) { + requireNonNull(sex); + checkArgument(isValidGender(sex), MESSAGE_GENDER_CONSTRAINTS); + this.value = sex; + } + + /** + * Returns true if a given string is a valid weight. + */ + public static boolean isValidGender(String test) { + return test.matches(GENDER_VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Weight // instanceof handles nulls + && this.value.equals(((Weight) 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 857bfcdc3c9d..d007afcb4566 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -20,19 +20,21 @@ public class Person { private final Email email; private final Address address; private final Weight weight; + private final Gender gender; private final UniqueTagList tags; /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Address address, Weight weight, Set tags) { + public Person(Name name, Phone phone, Email email, Address address, Weight weight, Gender gender, Set tags) { requireAllNonNull(name, phone, email, address, weight, tags); this.name = name; this.phone = phone; this.email = email; this.address = address; this.weight = weight; + this.gender = gender; // protect internal tags from changes in the arg list this.tags = new UniqueTagList(tags); } @@ -55,6 +57,7 @@ public Address getAddress() { public Weight getWeight() { return weight; } + public Gender getGender() { return gender; } /** * Returns an immutable tag set, which throws {@code UnsupportedOperationException} * if modification is attempted. @@ -79,13 +82,14 @@ public boolean equals(Object other) { && otherPerson.getEmail().equals(this.getEmail()) && otherPerson.getAddress().alphabeticallyEquals(this.getAddress()) - && otherPerson.getWeight().equals(this.getWeight()); + && otherPerson.getWeight().equals(this.getWeight()) + && otherPerson.getGender().equals(this.getGender()); } @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, address, weight, tags); + return Objects.hash(name, phone, email, address, weight, gender, tags); } @Override @@ -100,6 +104,8 @@ public String toString() { .append(getAddress()) .append(" Weight: ") .append(getWeight()) + .append(" Gender: ") + .append(getGender()) .append(" Tags: "); getTags().forEach(builder::append); return builder.toString(); diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index cdd6fdf9634f..28d02cf1760b 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -7,6 +7,7 @@ import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Gender; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -21,22 +22,22 @@ 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 Address("Blk 30 Geylang Street 29, #06-40"), new Weight("55.5"), + new Address("Blk 30 Geylang Street 29, #06-40"), new Weight("55.5"),new Gender("M"), 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 Weight("55.5"), + new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), new Weight("55.5"),new Gender("F"), 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 Weight("55.5"), + new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), new Weight("55.5"),new Gender("F"), 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 Weight("55.5"), + new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), new Weight("55.5"),new Gender("M"), 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 Weight("55.5"), + new Address("Blk 47 Tampines Street 20, #17-35"), new Weight("55.5"),new Gender("M"), 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 Weight("55.5"), + new Address("Blk 45 Aljunied Street 85, #11-31"), new Weight("55.5"),new Gender("M"), getTagSet("colleagues")) }; } diff --git a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java index 2c76ea1c4fb9..9a573d799aee 100644 --- a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java @@ -11,6 +11,7 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; +import seedu.address.model.person.Gender; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; @@ -34,6 +35,8 @@ public class XmlAdaptedPerson { private String address; @XmlElement(required = true) private String weight; + @XmlElement(required = true) + private String gender; @XmlElement private List tagged = new ArrayList<>(); @@ -48,12 +51,13 @@ public XmlAdaptedPerson() {} * Constructs an {@code XmlAdaptedPerson} with the given person details. */ public XmlAdaptedPerson(String name, String phone, String email, String address, - String weight, List tagged) { + String weight, String gender, List tagged) { this.name = name; this.phone = phone; this.email = email; this.address = address; this.weight = weight; + this.gender = gender; if (tagged != null) { this.tagged = new ArrayList<>(tagged); } @@ -70,6 +74,7 @@ public XmlAdaptedPerson(Person source) { email = source.getEmail().value; address = source.getAddress().value; weight = source.getWeight().value; + gender = source.getGender().value; tagged = new ArrayList<>(); for (Tag tag : source.getTags()) { tagged.add(new XmlAdaptedTag(tag)); @@ -127,8 +132,17 @@ public Person toModelType() throws IllegalValueException { } final Weight weight = new Weight(this.weight); + if (this.gender == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Gender.class.getSimpleName())); + } + if (!Gender.isValidGender(this.gender)) { + throw new IllegalValueException(Gender.MESSAGE_GENDER_CONSTRAINTS); + } + final Gender gender = new Gender(this.gender); + + final Set tags = new HashSet<>(personTags); - return new Person(name, phone, email, address, weight, tags); + return new Person(name, phone, email, address, weight, gender, tags); } @Override @@ -147,6 +161,7 @@ public boolean equals(Object other) { && Objects.equals(email, otherPerson.email) && Objects.equals(address, otherPerson.address) && Objects.equals(weight, otherPerson.weight) + && Objects.equals(gender, otherPerson.gender) && tagged.equals(otherPerson.tagged); } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index ccbde2ad63f2..073d794898e8 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -39,6 +39,8 @@ public class PersonCard extends UiPart { @FXML private Label weight; @FXML + private Label gender; + @FXML private FlowPane tags; public PersonCard(Person person, int displayedIndex) { @@ -50,6 +52,7 @@ public PersonCard(Person person, int displayedIndex) { address.setText(person.getAddress().value); email.setText(person.getEmail().value); weight.setText(person.getWeight().value); + gender.setText(person.getGender().value); person.getTags().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 a7cb901fc9b1..0424d9186257 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -10,7 +10,7 @@ - + @@ -27,6 +27,7 @@