From ea05efd3519b9b5415bd8bbd42748eb7e84540a5 Mon Sep 17 00:00:00 2001 From: OscarWang114 Date: Thu, 9 Nov 2017 02:48:50 +0800 Subject: [PATCH 1/5] Build Portfolio --- docs/DeveloperGuide.adoc | 12 +++++--- docs/team/oscarwang.adoc | 66 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 8 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 367571b65530..9ed9dcadc761 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -334,7 +334,7 @@ the `EmptyFieldException` is no longer unique to the empty prefix and thus, ther which is removed from the constructor of the exception. // end::autofill[] // tag::add[] -=== Making Name as the only compulsory field in Add Command +=== Making NAME the only compulsory field in Add Command The `add` command follows the format below: @@ -342,7 +342,7 @@ The `add` command follows the format below: This means when adding a new person in LISA, the user only needs to provide value for the compulsory `NAME` field. Every other field is optional. -Every field has one corresponding class. Inside each class, there exists a `final String FIELD_VALIDATION_REGEX` used for validation during construction. +Every field in a person corresponds to one class type. Inside each class, there exists a `final String FIELD_VALIDATION_REGEX` used for validation during construction. For instance, the `PHONE` field has `Phone` class containing a `PHONE_VALIDATION_REGEX` which only accepts numbers that are at least three digits long: [source,java] ---- @@ -387,7 +387,7 @@ If a field is not provided during input, an object with the value of an empty st An alternative implementation would be "Do not create the field object at all if it is not specified in the user input". -This approach is more flexible, but may require resolving `null` value problems when adding and editing a person. +This approach is more flexible, but may require resolving " value equals to `null` " and `NullPointerException` when adding and editing a person. // end::add[] // tag::dob @@ -681,12 +681,14 @@ The rest of the execution then, follows closely to the case where the command is // end::searchbox[] // tag::li[] -=== Addition of Life Insurances +=== Life Insurances: +`since v1.3` +// end::li[] // end::addli[] // tag::addli[] -=== Adding a Life Insurance: `addli` +=== Add Life Insurance Command: `since v1.4` Adds a life insurance in Lisa + diff --git a/docs/team/oscarwang.adoc b/docs/team/oscarwang.adoc index 433b07a8bf2c..612f19b47bbf 100644 --- a/docs/team/oscarwang.adoc +++ b/docs/team/oscarwang.adoc @@ -4,9 +4,9 @@ ifdef::env-github,env-browser[:outfilesuffix: .adoc] :stylesDir: ../stylesheets == LISA: Levels Integrated Secretarial Agent -LISA: Levels Integrated Secretarial Agent is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 6 kLoC. +LISA: Levels Integrated Secretarial Agent is a desktop address book application designed for insurance agents to manage the complex relationship between the providers and clients. It is developed by enhancing the original program "addressbook-level4" provided in class for teaching Software Engineering principles. While the main user interactions happen across CLI, LISA also has a GUI built with JavaFX. It is written in Java, and has about 6 kLoC. -*Code contributed*: [https://github.com[Functional code]] [https://github.com[Test code]] {give links to collated code files} +*Code contributed*: [https://github.com/CS2103AUG2017-T13-B1/main/tree/master/collated/main/OscarWang114.md[Functional code]] [https://github.com/CS2103AUG2017-T13-B1/main/tree/master/collated/test/OscarWang114.md[Test code]] === Enhancement Added: 'add' command with only one compulsory field: NAME @@ -16,7 +16,6 @@ LISA: Levels Integrated Secretarial Agent is a desktop address book application #Start of Extract [from: User Guide]# include::../UserGuide.adoc[tag=add] -include::../UserGuide.adoc[tag=addli] #End of Extract# @@ -32,6 +31,61 @@ include::../UserGuide.adoc[tag=addli] #Start of Extract [from: Developer Guide]# include::../DeveloperGuide.adoc[tag=add] + +#End of Extract# + +--- + +=== Enhancement Added: Life Insurances + +==== External behavior + +--- +#Start of Extract [from: User Guide]# + +include::../UserGuide.adoc[tag=li] + +#End of Extract# + +--- + +==== Justification + +{Justify the need for, and the current design (i.e. external behavior) of, the feature} + +==== Implementation + +--- +#Start of Extract [from: Developer Guide]# + +include::../DeveloperGuide.adoc[tag=ali] + +#End of Extract# + +--- + +=== Enhancement Added: 'addli' command for adding life insurances + +==== External behavior + +--- +#Start of Extract [from: User Guide]# + +include::../UserGuide.adoc[tag=addli] + +#End of Extract# + +--- + +==== Justification + +{Justify the need for, and the current design (i.e. external behavior) of, the feature} + +==== Implementation + +--- +#Start of Extract [from: Developer Guide]# + include::../DeveloperGuide.adoc[tag=addli] #End of Extract# @@ -40,5 +94,11 @@ include::../DeveloperGuide.adoc[tag=addli] === Enhancement Proposed: +- All the features listed above +- Implement date-related classes using Java 8 LocalDate +- Create a Gender class for each contact + === Other contributions +- Reviewed the majority of the Pull Requests submitted by other team members. +- Assisted several members personally in programming, debugging, and Git-related issues. From 0c82020073966b46b6f853cd33186eb8b29db7a6 Mon Sep 17 00:00:00 2001 From: OscarWang114 Date: Thu, 9 Nov 2017 11:10:23 +0800 Subject: [PATCH 2/5] Collate code --- collated/main/OscarWang114.md | 358 +++++++++++++++------------------- collated/test/OscarWang114.md | 54 +++-- 2 files changed, 193 insertions(+), 219 deletions(-) diff --git a/collated/main/OscarWang114.md b/collated/main/OscarWang114.md index 6049bc18d36a..dadbafc37173 100644 --- a/collated/main/OscarWang114.md +++ b/collated/main/OscarWang114.md @@ -34,13 +34,14 @@ public interface ThrowingConsumer extends Consumer { ###### /java/seedu/address/logic/commands/AddCommand.java ``` java public static final String MESSAGE_USAGE = concatenateCommandWords(COMMAND_WORDS) - + ": Adds a person to the address book. " + + ": Adds a person to Lisa. " + "Parameters: " + PREFIX_NAME + "NAME " + "[" + PREFIX_PHONE + "PHONE] " + "[" + PREFIX_EMAIL + "EMAIL] " + "[" + PREFIX_ADDRESS + "ADDRESS] " + "[" + PREFIX_DOB + "DATE OF BIRTH] " + + "[" + PREFIX_GENDER + "GENDER] " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " @@ -48,6 +49,7 @@ public interface ThrowingConsumer extends Consumer { + PREFIX_EMAIL + "johnd@example.com " + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " + PREFIX_DOB + "20 01 1997 " + + PREFIX_GENDER + "Male " + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; ``` @@ -62,12 +64,14 @@ public interface ThrowingConsumer extends Consumer { private Email email; private Address address; private DateOfBirth dateofbirth; + private Gender gender; public AddPersonOptionalFieldDescriptor() { this.phone = new Phone(); this.email = new Email(); this.address = new Address(); this.dateofbirth = new DateOfBirth(); + this.gender = new Gender(); } public void setPhone(Phone phone) { @@ -102,6 +106,14 @@ public interface ThrowingConsumer extends Consumer { return dateofbirth; } + public void setGender(Gender gender) { + this.gender = gender; + } + + public Gender getGender() { + return gender; + } + @Override public boolean equals(Object other) { // short circuit if same object @@ -121,7 +133,8 @@ public interface ThrowingConsumer extends Consumer { return getPhone().equals(a.getPhone()) && getEmail().equals(a.getEmail()) && getAddress().equals(a.getAddress()) - && getDateOfBirth().equals(a.getDateOfBirth()); + && getDateOfBirth().equals(a.getDateOfBirth()) + && getGender().equals(a.getGender()); } } } @@ -129,56 +142,52 @@ public interface ThrowingConsumer extends Consumer { ###### /java/seedu/address/logic/commands/AddLifeInsuranceCommand.java ``` java /** - * Creates an insurance relationship in the address book. + * Creates an insurance in Lisa */ public class AddLifeInsuranceCommand extends UndoableCommand { - public static final String[] COMMAND_WORDS = {"addli", "ali", "+"}; + public static final String[] COMMAND_WORDS = {"addli", "ali", "+li"}; public static final String COMMAND_WORD = "addli"; public static final String MESSAGE_USAGE = concatenateCommandWords(COMMAND_WORDS) - + ": Creates an insurance relationship. " + + ": Adds an insurance to Lisa. " + "Parameters: " + + PREFIX_NAME + "INSURANCE_NAME " + PREFIX_OWNER + "OWNER " + PREFIX_INSURED + "INSURED " + PREFIX_BENEFICIARY + "BENEFICIARY " - + PREFIX_CONTRACT + "CONTRACT" + + PREFIX_CONTRACT + "CONTRACT " + PREFIX_PREMIUM + "PREMIUM " + PREFIX_SIGNING_DATE + "SIGNING_DATE " + PREFIX_EXPIRY_DATE + "EXPIRY_DATE\n" + "Example: " + COMMAND_WORD + " " - + PREFIX_OWNER + "OWNER " - + PREFIX_INSURED + "INSURED " - + PREFIX_BENEFICIARY + "BENEFICIARY " - + PREFIX_CONTRACT + "CONTRACT" - + PREFIX_PREMIUM + "PREMIUM " - + PREFIX_SIGNING_DATE + "SIGNING_DATE " - + PREFIX_EXPIRY_DATE + "EXPIRY_DATE"; + + PREFIX_NAME + "Life Insurance " + + PREFIX_OWNER + "Alex Yeoh " + + PREFIX_INSURED + "John Doe " + + PREFIX_BENEFICIARY + "Mary Jane " + + PREFIX_CONTRACT + "normal_plan.pdf " + + PREFIX_PREMIUM + "500 " + + PREFIX_SIGNING_DATE + "01 11 2017 " + + PREFIX_EXPIRY_DATE + "01 11 2018 "; public static final String MESSAGE_SUCCESS = "New insurance added: %1$s"; - public static final String MESSAGE_DUPLICATE_INSURANCE = "This insurance already exists in the address book"; - public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book."; - private final LifeInsurance lifeInsuranceToAdd; + private final LifeInsurance lifeInsurance; /** - * Creates an AddLifeInsuranceCommand to add the specified {@code ReadOnlyInsurance} + * Creates an AddLifeInsuranceCommand to add the specified Insurance */ - public AddLifeInsuranceCommand(String ownerName, String insuredName, String beneficiaryName, - Double premium, String contractPath, LocalDate signingDate, - LocalDate expiryDate) { - this.lifeInsuranceToAdd = new LifeInsurance(ownerName, insuredName, beneficiaryName, - premium, contractPath, signingDate, expiryDate); + public AddLifeInsuranceCommand(ReadOnlyInsurance toAdd) { + lifeInsurance = new LifeInsurance(toAdd); } @Override public CommandResult executeUndoableCommand() throws CommandException { requireNonNull(model); List personList = model.getFilteredPersonList(); - List insuranceList = model.getInsuranceList(); - isAnyPersonInList(personList, lifeInsuranceToAdd); - model.addInsurance(lifeInsuranceToAdd); + isAnyPersonInList(personList, lifeInsurance); + model.addInsurance(lifeInsurance); - return new CommandResult(String.format(MESSAGE_SUCCESS, lifeInsuranceToAdd)); + return new CommandResult(String.format(MESSAGE_SUCCESS, lifeInsurance)); } @Override @@ -189,25 +198,23 @@ public class AddLifeInsuranceCommand extends UndoableCommand { //TODO: need to compare every nonstatic class member. } - /** - * Check if all the Person parameters required to create an insurance are inside the list - */ - public void isAnyPersonInList(List list, LifeInsurance lifeInsurance) { - String ownerName = lifeInsurance.getOwner().getName(); - String insuredName = lifeInsurance.getInsured().getName(); - String beneficiaryName = lifeInsurance.getBeneficiary().getName(); - for (ReadOnlyPerson person: list) { - String lowerCaseName = person.getName().toString().toLowerCase(); - if (lowerCaseName.equals(ownerName)) { - lifeInsurance.getOwner().setPerson(person); - } - if (lowerCaseName.equals(insuredName)) { - lifeInsurance.getInsured().setPerson(person); - } - if (lowerCaseName.equals(beneficiaryName)) { - lifeInsurance.getBeneficiary().setPerson(person); - } - } +``` +###### /java/seedu/address/logic/Logic.java +``` java + /** Returns an unmodifiable view of the list of insurances */ + ObservableList getFilteredInsuranceList(); +``` +###### /java/seedu/address/logic/LogicManager.java +``` java + @Override + public ObservableList getFilteredInsuranceList() { + return model.getFilteredInsuranceList(); + } + // + + @Override + public ListElementPointer getHistorySnapshot() { + return new ListElementPointer(history.getHistory()); } } ``` @@ -221,7 +228,7 @@ public class AddLifeInsuranceCommand extends UndoableCommand { public AddCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap; argMultimap = ArgumentTokenizer.tokenize( - args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_DOB, PREFIX_TAG); + args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_DOB, PREFIX_GENDER, PREFIX_TAG); if (!isNamePrefixPresent(argMultimap, PREFIX_NAME)) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); @@ -242,13 +249,16 @@ public class AddLifeInsuranceCommand extends UndoableCommand { .ifPresent(addPersonOptionalFieldDescriptor::setAddress); ParserUtil.parseDateOfBirth(argMultimap.getValue(PREFIX_DOB)) .ifPresent(addPersonOptionalFieldDescriptor::setDateOfBirth); + ParserUtil.parseGender(argMultimap.getValue(PREFIX_GENDER)) + .ifPresent(addPersonOptionalFieldDescriptor::setGender); Phone phone = addPersonOptionalFieldDescriptor.getPhone(); Email email = addPersonOptionalFieldDescriptor.getEmail(); Address address = addPersonOptionalFieldDescriptor.getAddress(); DateOfBirth dob = addPersonOptionalFieldDescriptor.getDateOfBirth(); + Gender gender = addPersonOptionalFieldDescriptor.getGender(); - ReadOnlyPerson person = new Person(name, phone, email, address, dob, tagList); + ReadOnlyPerson person = new Person(name, phone, email, address, dob, gender, tagList); return new AddCommand(person); } catch (IllegalValueException ive) { @@ -280,16 +290,17 @@ public class AddLifeInsuranceCommandParser implements Parser argumentMultimap.getValue(prefix).isPresent()); } } +``` +###### /java/seedu/address/logic/parser/ParserUtil.java +``` java + /** + * Parses a {@code Optional owner} into an {@code Optional} if {@code owner} is present. + * See header comment of this class regarding the use of {@code Optional} parameters. + */ + public static Optional parseNameForInsurance(Optional name) throws IllegalValueException { + requireNonNull(name); + return name.isPresent() ? Optional.of(name.get()) : Optional.empty(); + } + /** + * Parses a {@code Optional premium} into an {@code Optional} if {@code premium} is present. + * See header comment of this class regarding the use of {@code Optional} parameters. + */ + public static Optional parsePremium(Optional premium) throws IllegalValueException { + requireNonNull(premium); + return premium.isPresent() ? Optional.of(Double.parseDouble(premium.get())) : Optional.empty(); + } + /** + * Parses a {@code Optional contract} into an {@code Optional} if {@code contract} is present. + * See header comment of this class regarding the use of {@code Optional} parameters. + */ + public static Optional parseContract(Optional contract) throws IllegalValueException { + requireNonNull(contract); + return contract.isPresent() ? Optional.of(contract.get()) : Optional.empty(); + } + ``` ###### /java/seedu/address/model/AddressBook.java ``` java @@ -344,7 +386,7 @@ public class AddLifeInsuranceCommandParser implements Parser { + insurance.resetAllInsurancePerson(); String owner = insurance.getOwner().getName(); String insured = insurance.getInsured().getName(); String beneficiary = insurance.getBeneficiary().getName(); persons.forEach(person -> { - person.clearLifeInsuranceIds(); if (person.getName().fullName.equals(owner)) { insurance.setOwner(person); person.addLifeInsuranceIds(id); @@ -374,13 +416,14 @@ public class AddLifeInsuranceCommandParser implements Parser) person -> { List idList = person.getLifeInsuranceIds(); if (!idList.isEmpty()) { @@ -490,6 +533,8 @@ public class LifeInsurance implements ReadOnlyInsurance { */ public interface ReadOnlyInsurance { + String getInsuranceName(); + StringProperty insuranceNameProperty(); ObjectProperty idProperty(); String getId(); EnumMap getRoleToPersonNameMap(); @@ -534,32 +579,9 @@ public class UniqueLifeInsuranceList implements Iterable { public void add(ReadOnlyInsurance toAdd) { requireNonNull(toAdd); internalList.add(new LifeInsurance(toAdd)); + sortInsurances(); } - /** - * Returns the backing list as an unmodifiable {@code ObservableList}. - */ - public ObservableList asObservableList() { - return FXCollections.unmodifiableObservableList(mappedList); - } - - @Override - public Iterator iterator() { - return internalList.iterator(); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof UniqueLifeInsuranceList // instanceof handles nulls - && this.internalList.equals(((UniqueLifeInsuranceList) other).internalList)); - } - - @Override - public int hashCode() { - return internalList.hashCode(); - } -} ``` ###### /java/seedu/address/model/insurance/UniqueLifeInsuranceMap.java ``` java @@ -573,7 +595,8 @@ public class UniqueLifeInsuranceList implements Iterable { */ public class UniqueLifeInsuranceMap { - private final HashMap internalMap = new HashMap<>(); + private final ObservableMap internalMap = FXCollections.observableHashMap(); + private final ObservableList internalList = FXCollections.observableArrayList(); /** * Returns true if the map contains an equivalent UUID as the given argument. @@ -626,6 +649,7 @@ public class UniqueLifeInsuranceMap { public void setInsurances(UniqueLifeInsuranceMap replacement) { this.internalMap.clear(); this.internalMap.putAll(replacement.internalMap); + syncMappedListWithInternalMap(); } public void setInsurances(Map insurances) throws DuplicateInsuranceException { @@ -636,10 +660,17 @@ public class UniqueLifeInsuranceMap { setInsurances(replacement); } - public ObservableList asObservableList() { - return FXCollections.unmodifiableObservableList(FXCollections.observableArrayList(internalMap.values())); + /** + * Ensures that every insurance in the internalList: + * contains the same exact same collections of insurances as that of the insuranceMap. + */ + public void syncMappedListWithInternalMap() { + this.internalList.clear(); + this.internalList.setAll(this.internalMap.values()); } - +``` +###### /java/seedu/address/model/insurance/UniqueLifeInsuranceMap.java +``` java /** * Returns the backing map as an unmodifiable {@code ObservableList}. */ @@ -659,7 +690,11 @@ public class UniqueLifeInsuranceMap { public int hashCode() { return internalMap.hashCode(); } -} +``` +###### /java/seedu/address/model/Model.java +``` java + /** Returns an unmodifiable view of the filtered insurance list */ + ObservableList getFilteredInsuranceList(); ``` ###### /java/seedu/address/model/person/Address.java ``` java @@ -698,7 +733,7 @@ public class UniqueLifeInsuranceMap { */ public Person(ReadOnlyPerson source) { this(source.getName(), source.getPhone(), source.getEmail(), source.getAddress(), - source.getDateOfBirth(), source.getTags()); + source.getDateOfBirth(), source.getGender(), source.getTags()); if (source.getLifeInsuranceIds() != null) { this.lifeInsuranceIds = new SimpleObjectProperty<>(source.getLifeInsuranceIds()); } @@ -712,7 +747,7 @@ public class UniqueLifeInsuranceMap { ``` java public Person(ReadOnlyPerson source, LifeInsurance lifeInsurance) { this(source.getName(), source.getPhone(), source.getEmail(), source.getAddress(), - source.getDateOfBirth(), source.getTags()); + source.getDateOfBirth(), source.getGender(), source.getTags()); if (source.getLifeInsuranceIds() != null) { this.lifeInsuranceIds = new SimpleObjectProperty<>(source.getLifeInsuranceIds()); } @@ -799,6 +834,8 @@ public class UniqueLifeInsuranceMap { * JAXB-friendly version of the LifeInsurance. */ public class XmlAdaptedLifeInsurance { + @XmlElement(required = true) + private String insuranceName; @XmlElement(required = true) private String owner; @XmlElement(required = true) @@ -827,6 +864,7 @@ public class XmlAdaptedLifeInsurance { * @param source future changes to this will not affect the created XmlAdaptedLifeInsurance */ public XmlAdaptedLifeInsurance(ReadOnlyInsurance source) { + insuranceName = source.getInsuranceName(); owner = source.getOwner().getName(); insured = source.getInsured().getName(); beneficiary = source.getBeneficiary().getName(); @@ -843,7 +881,7 @@ public class XmlAdaptedLifeInsurance { */ public LifeInsurance toModelType() throws IllegalValueException { - return new LifeInsurance(this.owner, this.insured, this.beneficiary, this.premium, + return new LifeInsurance(this.insuranceName, this.owner, this.insured, this.beneficiary, this.premium, this.contractPath, this.signingDate, this.expiryDate); } } @@ -874,8 +912,9 @@ public class XmlAdaptedLifeInsurance { final Email email = this.email.equals("") ? new Email() : new Email(this.email); final Address address = this.address.equals("") ? new Address() : new Address(this.address); final DateOfBirth dob = this.dob.equals("") ? new DateOfBirth() : new DateOfBirth(this.dob); + final Gender gender = this.gender.equals("") ? new Gender() : new Gender(this.gender); final Set tags = new HashSet<>(personTags); - return new Person(name, phone, email, address, dob, tags, personLifeInsuranceIds); + return new Person(name, phone, email, address, dob, gender, tags, personLifeInsuranceIds); } ``` ###### /java/seedu/address/storage/XmlSerializableAddressBook.java @@ -904,11 +943,6 @@ public class XmlAdaptedLifeInsurance { ``` ###### /java/seedu/address/ui/InsuranceListPanel.java ``` java -/** - * The Insurance Panel of the App. - */ -public class InsuranceListPanel extends UiPart { - private static final String FXML = "InsuranceListPanel.fxml"; private final Logger logger = LogsCenter.getLogger(this.getClass()); @@ -945,45 +979,10 @@ public class InsuranceListPanel extends UiPart { setEventHandlerForSelectionChangeEvent(); } - - - private void setEventHandlerForSelectionChangeEvent() { - insuranceListView.getSelectionModel().selectedItemProperty() - .addListener((observable, oldValue, newValue) -> { - if (newValue != null) { - logger.fine("Selection in insurance list panel changed to : '" + newValue + "'"); - raise(new InsurancePanelSelectionChangedEvent(newValue)); - } - }); - } - - /** - * Custom {@code ListCell} that displays the graphics of a {@code InsuranceProfile}. - */ - class InsuranceListViewCell extends ListCell { - @Override - protected void updateItem(InsuranceProfile insurance, boolean empty) { - super.updateItem(insurance, empty); - - if (empty || insurance == null) { - setGraphic(null); - setText(null); - } else { - setGraphic(insurance.getRoot()); - } - } - } -} ``` ###### /java/seedu/address/ui/InsuranceProfile.java ``` java -/** - * The Profile Panel of the App. - */ -public class InsuranceProfile extends UiPart { - private static final String FXML = "InsuranceProfile.fxml"; - private static final String PDFFOLDERPATH = "data/"; private final Logger logger = LogsCenter.getLogger(this.getClass()); private File insuranceFile; @@ -1000,45 +999,43 @@ public class InsuranceProfile extends UiPart { @FXML private Label premium; @FXML - private Label contractPath; - @FXML - private Label signingDate; - @FXML - private Label expiryDate; + private Label insuranceName; + public InsuranceProfile() { super(FXML); enableNameToProfileLink(insurance); registerAsAnEventHandler(this); } - ``` ###### /java/seedu/address/ui/ProfilePanel.java ``` java /** - * Load person page with empty fields and default message + * Load person page with only his/her name with person does not exist in Lisa message */ private void loadPersonPage(StringProperty name) { unbindListenersAndClearText(); this.name.textProperty().bind(Bindings.convert(name)); - this.address.setText(PERSON_DOES_NOT_EXIST_MESSAGE); + this.address.setText(PERSON_DOES_NOT_EXIST_IN_LISA_MESSAGE); } ``` ###### /java/seedu/address/ui/ProfilePanel.java ``` java /** - * unbind all listeners + * Unbind all listeners and reset the text values to {@code null} */ private void unbindListenersAndClearText() { name.textProperty().unbind(); phone.textProperty().unbind(); address.textProperty().unbind(); dob.textProperty().unbind(); + gender.textProperty().unbind(); email.textProperty().unbind(); name.setText(null); phone.setText(null); address.setText(null); dob.setText(null); + gender.setText(null); email.setText(null); insuranceHeader.setText(null); } @@ -1079,68 +1076,29 @@ public class InsuranceProfile extends UiPart { ``` ###### /resources/view/InsuranceProfile.fxml ``` fxml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + ``` diff --git a/collated/test/OscarWang114.md b/collated/test/OscarWang114.md index ed5020f0d08c..3068c9029520 100644 --- a/collated/test/OscarWang114.md +++ b/collated/test/OscarWang114.md @@ -5,38 +5,49 @@ 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).withDateOfBirth(VALID_DOB_AMY) - .withTags().build(); - assertParseSuccess(parser, AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + DOB_DESC_AMY, new AddCommand(expectedPerson)); + .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) + .withDateOfBirth(VALID_DOB_AMY).withGender(VALID_GENDER_AMY).withTags().build(); + assertParseSuccess(parser, AddCommand.COMMAND_WORD + NAME_DESC_AMY + + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + DOB_DESC_AMY + + GENDER_DESC_AMY, new AddCommand(expectedPerson)); // missing phone prefix expectedPerson = new PersonBuilder().withName(VALID_NAME_AMY).withEmptyPhone() .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withDateOfBirth(VALID_DOB_AMY) - .withTags().build(); + .withGender(VALID_GENDER_AMY).withTags().build(); assertParseSuccess(parser, AddCommand.COMMAND_WORD + NAME_DESC_AMY - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + DOB_DESC_AMY, new AddCommand(expectedPerson)); + + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + DOB_DESC_AMY + GENDER_DESC_AMY, new AddCommand(expectedPerson)); // missing email prefix expectedPerson = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) .withEmptyEmail().withAddress(VALID_ADDRESS_AMY).withDateOfBirth(VALID_DOB_AMY) - .withTags().build(); + .withGender(VALID_GENDER_AMY).withTags().build(); assertParseSuccess(parser, AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY - + ADDRESS_DESC_AMY + DOB_DESC_AMY, new AddCommand(expectedPerson)); + + ADDRESS_DESC_AMY + DOB_DESC_AMY + + GENDER_DESC_AMY, new AddCommand(expectedPerson)); // missing address prefix expectedPerson = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) .withEmail(VALID_EMAIL_AMY).withDateOfBirth(VALID_DOB_AMY) - .withEmptyAddress().withTags().build(); + .withGender(VALID_GENDER_AMY).withEmptyAddress().withTags().build(); assertParseSuccess(parser, AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY - + EMAIL_DESC_AMY + DOB_DESC_AMY, new AddCommand(expectedPerson)); + + EMAIL_DESC_AMY + DOB_DESC_AMY + + GENDER_DESC_AMY, new AddCommand(expectedPerson)); // missing date of birth prefix expectedPerson = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) - .withEmptyDateOfBirth().withTags().build(); + .withGender(VALID_GENDER_AMY).withEmptyDateOfBirth().withTags().build(); assertParseSuccess(parser, AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY, new AddCommand(expectedPerson)); + + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + + GENDER_DESC_AMY, new AddCommand(expectedPerson)); + + // missing gender prefix + expectedPerson = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) + .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withDateOfBirth(VALID_DOB_AMY) + .withEmptyGender().withTags().build(); + assertParseSuccess(parser, AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + DOB_DESC_AMY, new AddCommand(expectedPerson)); } ``` ###### /java/seedu/address/testutil/PersonBuilder.java @@ -71,39 +82,44 @@ ``` ###### /java/seedu/address/testutil/TypicalPersons.java ``` java + public static final ReadOnlyPerson AMY_NO_PHONE = new PersonBuilder().withName(VALID_NAME_AMY).withEmptyPhone() .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) - .withDateOfBirth(VALID_DOB_AMY).withTags(VALID_TAG_FRIEND).build(); + .withDateOfBirth(VALID_DOB_AMY).withGender(VALID_GENDER_AMY).withTags(VALID_TAG_FRIEND).build(); public static final ReadOnlyPerson AMY_NO_EMAIL = new PersonBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_AMY).withEmptyEmail().withAddress(VALID_ADDRESS_AMY) .withDateOfBirth(VALID_DOB_AMY).withTags(VALID_TAG_FRIEND) - .build(); + .withGender(VALID_GENDER_AMY).build(); public static final ReadOnlyPerson AMY_NO_ADDRESS = new PersonBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withEmptyAddress() .withDateOfBirth(VALID_DOB_AMY).withTags(VALID_TAG_FRIEND) - .build(); + .withGender(VALID_GENDER_AMY).build(); + ``` ###### /java/systemtests/AddCommandSystemTest.java ``` java /* Case: missing phone -> added */ command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + EMAIL_DESC_AMY - + ADDRESS_DESC_AMY + DOB_DESC_AMY + TAG_DESC_FRIEND; + + ADDRESS_DESC_AMY + DOB_DESC_AMY + + GENDER_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, AMY_NO_PHONE); /* Case: missing email -> added */ command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY - + ADDRESS_DESC_AMY + DOB_DESC_AMY + TAG_DESC_FRIEND; + + ADDRESS_DESC_AMY + DOB_DESC_AMY + + GENDER_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, AMY_NO_EMAIL); /* Case: missing address -> added */ command = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY - + EMAIL_DESC_AMY + DOB_DESC_AMY + TAG_DESC_FRIEND; + + EMAIL_DESC_AMY + DOB_DESC_AMY + + GENDER_DESC_AMY + TAG_DESC_FRIEND; assertCommandSuccess(command, AMY_NO_ADDRESS); ``` ###### /java/systemtests/AddCommandSystemTest.java ``` java /* Case: missing name -> rejected */ command = AddCommand.COMMAND_WORD + PHONE_DESC_AMY + EMAIL_DESC_AMY - + ADDRESS_DESC_AMY + DOB_DESC_AMY; + + ADDRESS_DESC_AMY + GENDER_DESC_AMY + DOB_DESC_AMY; assertCommandFailure(command, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); ``` From 733d0a7b2f4aa2d763335f3176bb21d743c750d8 Mon Sep 17 00:00:00 2001 From: OscarWang114 Date: Thu, 9 Nov 2017 11:10:49 +0800 Subject: [PATCH 3/5] Collate code --- .../seedu/address/logic/commands/AddLifeInsuranceCommand.java | 2 +- .../seedu/address/model/insurance/UniqueLifeInsuranceMap.java | 4 +++- src/main/java/seedu/address/ui/InsuranceListPanel.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddLifeInsuranceCommand.java b/src/main/java/seedu/address/logic/commands/AddLifeInsuranceCommand.java index fc13578b8f78..60abb669618e 100644 --- a/src/main/java/seedu/address/logic/commands/AddLifeInsuranceCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddLifeInsuranceCommand.java @@ -22,7 +22,7 @@ * Creates an insurance in Lisa */ public class AddLifeInsuranceCommand extends UndoableCommand { - public static final String[] COMMAND_WORDS = {"addli", "ali", "+"}; + public static final String[] COMMAND_WORDS = {"addli", "ali", "+li"}; public static final String COMMAND_WORD = "addli"; public static final String MESSAGE_USAGE = concatenateCommandWords(COMMAND_WORDS) diff --git a/src/main/java/seedu/address/model/insurance/UniqueLifeInsuranceMap.java b/src/main/java/seedu/address/model/insurance/UniqueLifeInsuranceMap.java index 530336fcbff3..5549ade63c03 100644 --- a/src/main/java/seedu/address/model/insurance/UniqueLifeInsuranceMap.java +++ b/src/main/java/seedu/address/model/insurance/UniqueLifeInsuranceMap.java @@ -99,7 +99,7 @@ public void syncMappedListWithInternalMap() { this.internalList.clear(); this.internalList.setAll(this.internalMap.values()); } - //author + //@@author //@@author RSJunior37 /** @@ -112,6 +112,7 @@ public ObservableList asObservableList() { } //@@author + //@@author OscarWang114 /** * Returns the backing map as an unmodifiable {@code ObservableList}. */ @@ -131,4 +132,5 @@ public boolean equals(Object other) { public int hashCode() { return internalMap.hashCode(); } + //@@author } diff --git a/src/main/java/seedu/address/ui/InsuranceListPanel.java b/src/main/java/seedu/address/ui/InsuranceListPanel.java index 541c9c50b56a..2d8933807bd1 100644 --- a/src/main/java/seedu/address/ui/InsuranceListPanel.java +++ b/src/main/java/seedu/address/ui/InsuranceListPanel.java @@ -20,12 +20,12 @@ import seedu.address.logic.commands.SelectCommand.PanelChoice; import seedu.address.model.insurance.ReadOnlyInsurance; -//@@author OscarWang114 /** * The Insurance Panel of the App. */ public class InsuranceListPanel extends UiPart { + //@@author OscarWang114 private static final String FXML = "InsuranceListPanel.fxml"; private final Logger logger = LogsCenter.getLogger(this.getClass()); @@ -62,6 +62,7 @@ public void setConnections(ObservableList insuranceList) { setEventHandlerForSelectionChangeEvent(); } + //@@author //@@author RSJunior37 private void setEventHandlerForSelectionChangeEvent() { From df791c3379e02c19500f97d1edbcfba073e1a735 Mon Sep 17 00:00:00 2001 From: OscarWang114 Date: Thu, 9 Nov 2017 11:11:12 +0800 Subject: [PATCH 4/5] Update DeveloperGuide and porfolio --- docs/DeveloperGuide.adoc | 18 ++++-------------- docs/team/oscarwang.adoc | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 9ed9dcadc761..f87b3f288715 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -681,27 +681,17 @@ The rest of the execution then, follows closely to the case where the command is // end::searchbox[] // tag::li[] -=== Life Insurances: +=== Reading and Storing Life Insurances: `since v1.3` -// end::li[] -// end::addli[] +TBA +// end::li[] // tag::addli[] === Add Life Insurance Command: `since v1.4` -Adds a life insurance in Lisa + - -Format: `add n/NAME o/OWNER i/INSURED b/BENEFICIARY pr/PREMIUM c/CONTRACT_FILE_PATH sd/SIGNING_DATE ed/EXPIRY_DATE` - -Examples: - -* `addli n/Term Life o/Alex Yeoh i/John Doe b/Mary Jane c/TermLife.pdf - pr/600 sd/01 11 2017 ed/01 11 2037` -* `addli n/Whole Life o/Bernice Yu i/David Li b/Roy Balakrishnan c/WholeLife.pdf - pr/8500 sd/01 11 2017 ed/01 11 2117` - +TBA // end::addli[] // tag::print[] diff --git a/docs/team/oscarwang.adoc b/docs/team/oscarwang.adoc index 612f19b47bbf..5eb0dc895480 100644 --- a/docs/team/oscarwang.adoc +++ b/docs/team/oscarwang.adoc @@ -4,7 +4,10 @@ ifdef::env-github,env-browser[:outfilesuffix: .adoc] :stylesDir: ../stylesheets == LISA: Levels Integrated Secretarial Agent -LISA: Levels Integrated Secretarial Agent is a desktop address book application designed for insurance agents to manage the complex relationship between the providers and clients. It is developed by enhancing the original program "addressbook-level4" provided in class for teaching Software Engineering principles. While the main user interactions happen across CLI, LISA also has a GUI built with JavaFX. It is written in Java, and has about 6 kLoC. +LISA: Levels Integrated Secretarial Agent is a desktop address book application designed for insurance agents to manage the complex relationship between the providers and clients. +While the main user interactions happen across CLI, it also has a GUI built with JavaFX. +LISA is developed by enhancing the original program "addressbook-level4" provided in class for teaching Software Engineering principles. +The original program is written in Java, and has about 6 kLoC. *Code contributed*: [https://github.com/CS2103AUG2017-T13-B1/main/tree/master/collated/main/OscarWang114.md[Functional code]] [https://github.com/CS2103AUG2017-T13-B1/main/tree/master/collated/test/OscarWang114.md[Test code]] @@ -23,7 +26,8 @@ include::../UserGuide.adoc[tag=add] ==== Justification -{Justify the need for, and the current design (i.e. external behavior) of, the feature} +As a user, I can add contacts even if I only know his/her name. +In reality, it is unreasonable to require users to provide complete information of a person when adding his/her as a contact. ==== Implementation @@ -36,7 +40,7 @@ include::../DeveloperGuide.adoc[tag=add] --- -=== Enhancement Added: Life Insurances +=== Enhancement Added: Reading and Storing Life Insurances ==== External behavior @@ -51,14 +55,15 @@ include::../UserGuide.adoc[tag=li] ==== Justification -{Justify the need for, and the current design (i.e. external behavior) of, the feature} +This feature serves as a precursor of the implementation for the user story: As an insurance agent, I can specify the provider-client relationship among my contacts. + ==== Implementation --- #Start of Extract [from: Developer Guide]# -include::../DeveloperGuide.adoc[tag=ali] +include::../DeveloperGuide.adoc[tag=li] #End of Extract# @@ -79,7 +84,8 @@ include::../UserGuide.adoc[tag=addli] ==== Justification -{Justify the need for, and the current design (i.e. external behavior) of, the feature} +This feature is an implementation of the user story: As an insurance agent, I can specify the provider-client relationship among my contacts. +It is crucial for LISA to allow insurance agents to create insurances, a provider-client relationship in the contacts. ==== Implementation @@ -100,5 +106,6 @@ include::../DeveloperGuide.adoc[tag=addli] === Other contributions -- Reviewed the majority of the Pull Requests submitted by other team members. -- Assisted several members personally in programming, debugging, and Git-related issues. +- Reviewed the majority of the pull requests submitted by other team members. +- Assisted several team members personally in programming, debugging, and Git-related issues. +- Reported bugs in other team's product in acceptance testing. [https://github.com/CS2103AUG2017-F11-B3/main/issues/74[Bug 1]] [https://github.com/CS2103AUG2017-F11-B3/main/issues/73[Bug 2]] \ No newline at end of file From de019f58252cee57176d6ea77bbbd9e7479e5dd2 Mon Sep 17 00:00:00 2001 From: "WANG, Chih-Hao" <30998659+OscarWang114@users.noreply.github.com> Date: Wed, 8 Nov 2017 21:25:17 -0600 Subject: [PATCH 5/5] Fix style --- docs/team/oscarwang.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/team/oscarwang.adoc b/docs/team/oscarwang.adoc index 5eb0dc895480..33d240ff9cb8 100644 --- a/docs/team/oscarwang.adoc +++ b/docs/team/oscarwang.adoc @@ -108,4 +108,4 @@ include::../DeveloperGuide.adoc[tag=addli] - Reviewed the majority of the pull requests submitted by other team members. - Assisted several team members personally in programming, debugging, and Git-related issues. -- Reported bugs in other team's product in acceptance testing. [https://github.com/CS2103AUG2017-F11-B3/main/issues/74[Bug 1]] [https://github.com/CS2103AUG2017-F11-B3/main/issues/73[Bug 2]] \ No newline at end of file +- Reported bugs in other team's product in acceptance testing. [https://github.com/CS2103AUG2017-F11-B3/main/issues/74[Bug 1]] [https://github.com/CS2103AUG2017-F11-B3/main/issues/73[Bug 2]]