From ea0fc0cf3fe46366987888779e7678feb9355165 Mon Sep 17 00:00:00 2001 From: redcolorbicycle Date: Mon, 18 Mar 2024 03:22:54 +0800 Subject: [PATCH 01/34] implement house structure and logic, half replace address with individual components --- src/main/java/seedu/address/model/house/House.java | 2 ++ src/main/java/seedu/address/model/house/Landed.java | 2 ++ src/main/java/seedu/address/model/house/NonLanded.java | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 src/main/java/seedu/address/model/house/House.java create mode 100644 src/main/java/seedu/address/model/house/Landed.java create mode 100644 src/main/java/seedu/address/model/house/NonLanded.java diff --git a/src/main/java/seedu/address/model/house/House.java b/src/main/java/seedu/address/model/house/House.java new file mode 100644 index 00000000000..ed13ade5fa0 --- /dev/null +++ b/src/main/java/seedu/address/model/house/House.java @@ -0,0 +1,2 @@ +package seedu.address.model.house;public class House { +} diff --git a/src/main/java/seedu/address/model/house/Landed.java b/src/main/java/seedu/address/model/house/Landed.java new file mode 100644 index 00000000000..9e561fedfc5 --- /dev/null +++ b/src/main/java/seedu/address/model/house/Landed.java @@ -0,0 +1,2 @@ +package seedu.address.model.house;public class Landed { +} diff --git a/src/main/java/seedu/address/model/house/NonLanded.java b/src/main/java/seedu/address/model/house/NonLanded.java new file mode 100644 index 00000000000..3cf207d74f9 --- /dev/null +++ b/src/main/java/seedu/address/model/house/NonLanded.java @@ -0,0 +1,2 @@ +package seedu.address.model.house;public class NonLanded { +} From 43d3e7c54b8d57a52f8b5f824bcc97cc6c474fb7 Mon Sep 17 00:00:00 2001 From: redcolorbicycle Date: Mon, 18 Mar 2024 03:23:54 +0800 Subject: [PATCH 02/34] implement house structure and logic, half replace address with individual components --- .../address/logic/commands/AddCommand.java | 19 +++-- .../address/logic/commands/EditCommand.java | 22 ++++-- .../logic/parser/AddCommandParser.java | 52 +++++++++---- .../seedu/address/logic/parser/CliSyntax.java | 1 + .../logic/parser/EditCommandParser.java | 2 +- .../address/logic/parser/ParserUtil.java | 17 ++++ .../java/seedu/address/model/house/House.java | 78 ++++++++++++++++++- .../seedu/address/model/house/Landed.java | 20 ++++- .../seedu/address/model/house/NonLanded.java | 42 +++++++++- .../seedu/address/model/person/Person.java | 19 ++--- .../java/seedu/address/ui/PersonCard.java | 4 +- .../testutil/EditPersonDescriptorBuilder.java | 7 +- 12 files changed, 235 insertions(+), 48 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index a15f9bff5f2..89b4b9fbcf7 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -1,12 +1,7 @@ package seedu.address.logic.commands; 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_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_POSTALCODE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; @@ -26,14 +21,22 @@ public class AddCommand extends Command { + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " - + PREFIX_ADDRESS + "ADDRESS " + + PREFIX_HOUSINGTYPE + "HOUSINGTYPE" + + PREFIX_STREET + "STREET " + + PREFIX_BLOCK + "BLOCK " + + PREFIX_LEVEL + "LEVEL " + + PREFIX_UNITNUMBER + "UNITNUMBER " + PREFIX_POSTALCODE + "POSTAL CODE " + "[" + 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_HOUSINGTYPE + "HDB " + + PREFIX_STREET + "Clementi Ave 2 " + + PREFIX_BLOCK + "Block 311 " + + PREFIX_LEVEL + "Level 02" + + PREFIX_UNITNUMBER + "Unit 25" + PREFIX_POSTALCODE + "578578 " + 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 087310867c0..b26f378ed07 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -21,6 +21,7 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; +import seedu.address.model.house.House; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -98,10 +99,14 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); - Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); + Street updatedStreet = editPersonDescriptor.getStreet().orElse(personToEdit.getStreet()); + Level updatedLevel = editPersonDescriptor.getLevel().orElse(personToEdit.getLevel()); + Block updatedBlock = editPersonDescriptor.getBlock().orElse(personToEdit.getBlock()); + UnitNumber unitNumber = editPersonDescriptor.getUnitNumber().orElse(personToEdit.getUnitNumber()); + PostalCode postalCode = editPersonDescriptor.getPostalCode().orElse(personToEdit.getPostalCode()); Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, + return new Person(updatedName, updatedPhone, updatedEmail, updatedHouse, personToEdit.getPostalCode(), updatedTags); } @@ -137,7 +142,7 @@ public static class EditPersonDescriptor { private Name name; private Phone phone; private Email email; - private Address address; + private House house; private Set tags; public EditPersonDescriptor() { @@ -151,10 +156,11 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setName(toCopy.name); setPhone(toCopy.phone); setEmail(toCopy.email); - setAddress(toCopy.address); + setHouse(toCopy.house); setTags(toCopy.tags); } + /** * Returns true if at least one field is edited. */ @@ -186,12 +192,12 @@ public Optional getEmail() { return Optional.ofNullable(email); } - public void setAddress(Address address) { - this.address = address; + public void setHouse(House house) { + this.house = house; } - public Optional
getAddress() { - return Optional.ofNullable(address); + public Optional getHouse() { + return Optional.ofNullable(house); } /** diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index d3c61c760a6..7a1e07d5e0d 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -1,19 +1,14 @@ package seedu.address.logic.parser; import static seedu.address.logic.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_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_POSTALCODE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; import java.util.Set; import java.util.stream.Stream; import seedu.address.logic.commands.AddCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.house.PostalCode; +import seedu.address.model.house.*; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -32,25 +27,54 @@ public class AddCommandParser implements Parser { * @throws ParseException if the user input does not conform the expected format */ public AddCommand parse(String args) throws ParseException { + boolean HASBLOCK = true; + boolean HASLEVEL = true; ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, - PREFIX_POSTALCODE, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_HOUSINGTYPE, PREFIX_LEVEL, + PREFIX_EMAIL, PREFIX_BLOCK, PREFIX_STREET, PREFIX_UNITNUMBER, PREFIX_POSTALCODE, PREFIX_TAG); - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_POSTALCODE) + //include more here for buyer/seller? + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL) || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, - PREFIX_ADDRESS, PREFIX_POSTALCODE); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_HOUSINGTYPE, PREFIX_LEVEL, + PREFIX_EMAIL, PREFIX_BLOCK, PREFIX_STREET, PREFIX_UNITNUMBER, PREFIX_POSTALCODE); Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); 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()); + UnitNumber unitNumber = ParserUtil.parseUnitNumber(argMultimap.getValue(PREFIX_UNITNUMBER).get()); PostalCode postalCode = ParserUtil.parsePostalCode(argMultimap.getValue(PREFIX_POSTALCODE).get()); + Street street = ParserUtil.parseStreet(argMultimap.getValue(PREFIX_STREET).get()); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - Person person = new Person(name, phone, email, address, postalCode, tagList); + //NonLandeds might not have blocks, Landeds definitely do not have blocks. + if (!argMultimap.getValue(PREFIX_BLOCK).isPresent()) { + HASBLOCK = false; + } + + //Landeds do not have levels + if (!argMultimap.getValue(PREFIX_BLOCK).isPresent()) { + HASLEVEL = false; + } + + if (HASLEVEL && HASBLOCK) { + Block block = ParserUtil.parseBlock(argMultimap.getValue(PREFIX_BLOCK).get()); + Level level = ParserUtil.parseLevel(argMultimap.getValue(PREFIX_LEVEL).get()); + House house = new NonLanded(block, level, postalCode, street, unitNumber); + Person person = new Person(name, phone, email, house, postalCode, tagList); + return new AddCommand(person); + } else if (HASLEVEL) { + Level level = ParserUtil.parseLevel(argMultimap.getValue(PREFIX_LEVEL).get()); + House house = new NonLanded(level, postalCode, street, unitNumber); + Person person = new Person(name, phone, email, house, postalCode, tagList); + return new AddCommand(person); + } + + House house = new Landed(unitNumber, postalCode, street); + + Person person = new Person(name, phone, email, house, postalCode, tagList); return new AddCommand(person); } diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 11cdea69dfd..0b9b96b8a20 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_TAG = new Prefix("t/"); + public static final Prefix PREFIX_HOUSINGTYPE = new Prefix("type/"); public static final Prefix PREFIX_STREET = new Prefix("street/"); public static final Prefix PREFIX_LEVEL = new Prefix("level/"); public static final Prefix PREFIX_UNITNUMBER = new Prefix("unitNo/"); diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index 46b3309a78b..dc422732c37 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -56,7 +56,7 @@ public EditCommand parse(String args) throws ParseException { editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get())); } if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) { - editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get())); + editPersonDescriptor.setHouse(ParserUtil.parseHousing(argMultimap.getValue(PREFIX_HOUSE).get())); } parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags); diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 90f1aeae8a1..d8ddcfb3f6b 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -10,7 +10,10 @@ import seedu.address.commons.util.StringUtil; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.house.Block; +import seedu.address.model.house.House; +import seedu.address.model.house.Landed; import seedu.address.model.house.Level; +import seedu.address.model.house.NonLanded; import seedu.address.model.house.PostalCode; import seedu.address.model.house.Street; import seedu.address.model.house.UnitNumber; @@ -128,6 +131,20 @@ public static Set parseTags(Collection tags) throws ParseException return tagSet; } + /** + * Parses a {@code String street} into a {@code Street}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if the given {@code street} is invalid. + */ + public static void parseHousing(String name) throws ParseException { + requireNonNull(name); + String trimmedName = name.trim(); + if (!House.isValidName(trimmedName.toLowerCase())) { + throw new ParseException(House.MESSAGE_CONSTRAINTS); + } + } + /** * Parses a {@code String street} into a {@code Street}. * Leading and trailing whitespaces will be trimmed. diff --git a/src/main/java/seedu/address/model/house/House.java b/src/main/java/seedu/address/model/house/House.java index ed13ade5fa0..598300cc4be 100644 --- a/src/main/java/seedu/address/model/house/House.java +++ b/src/main/java/seedu/address/model/house/House.java @@ -1,2 +1,78 @@ -package seedu.address.model.house;public class House { +package seedu.address.model.house; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; +import seedu.address.model.person.Person; + +/** + * Represents a House. + */ +public class House { + public static final String MESSAGE_CONSTRAINTS = + "Housing types can only be HDB, Condominium or Landed."; + public static final String[] VALIDATION_REGEX = {"hdb", "condominium", "landed"}; + public final PostalCode postalCode; + public final Street street; + public final UnitNumber unitNumber; + + /** + * Constructs a {@code Level}. + * + * @param postalCode The postal code of the house. + * @param street The street of the house. + */ + public House(UnitNumber unitNumber, PostalCode postalCode, Street street) { + this.postalCode = postalCode; + this.street = street; + this.unitNumber = unitNumber; + } + + public House(UnitNumber unitNumber, House house) { + this.unitNumber = unitNumber; + this.postalCode = house.getPostalCode(); + this.street = house.getStreet(); + } + public House(PostalCode postalCode, House house) { + this.unitNumber = house.getUnitNumber(); + this.postalCode = house.getPostalCode(); + this.street = house.getStreet(); + } + public House(Street street, House house) { + this.unitNumber = house.getUnitNumber(); + this.postalCode = house.getPostalCode(); + this.street = street; + } + + public House(House house) { + this.unitNumber = house.getUnitNumber(); + this.postalCode = house.getPostalCode(); + this.street = house.getStreet(); + } + + public UnitNumber getUnitNumber() { + return unitNumber; + } + + public PostalCode getPostalCode() { + return postalCode; + } + + public Street getStreet() { + return street; + } + + public static boolean isValidName(String name) { + for (String element : VALIDATION_REGEX) { + if (element.equals(name)) { + return true; + } + } + return false; + } + + public String toString() { + return "HOMELESS"; + } + + } diff --git a/src/main/java/seedu/address/model/house/Landed.java b/src/main/java/seedu/address/model/house/Landed.java index 9e561fedfc5..8e700f71343 100644 --- a/src/main/java/seedu/address/model/house/Landed.java +++ b/src/main/java/seedu/address/model/house/Landed.java @@ -1,2 +1,20 @@ -package seedu.address.model.house;public class Landed { +package seedu.address.model.house; + +import seedu.address.model.person.Person; + +public class Landed extends House { + + /** + * Constructs a {@code Level}. + * + * @param postalCode The postal code of the house. + * @param street The street of the house. + */ + public Landed(UnitNumber unitNumber, PostalCode postalCode, Street street) { + super(unitNumber, postalCode, street); + } + @Override + public String toString() { + return unitNumber.toString() + " " + street.toString() + postalCode.toString(); + } } diff --git a/src/main/java/seedu/address/model/house/NonLanded.java b/src/main/java/seedu/address/model/house/NonLanded.java index 3cf207d74f9..7b41e36538e 100644 --- a/src/main/java/seedu/address/model/house/NonLanded.java +++ b/src/main/java/seedu/address/model/house/NonLanded.java @@ -1,2 +1,42 @@ -package seedu.address.model.house;public class NonLanded { +package seedu.address.model.house; + +import seedu.address.model.house.House; +import seedu.address.model.person.Person; + +public class NonLanded extends House{ + public final Block block; + public final Level level; + public final UnitNumber unitNumber; + + + /** + * Constructs a {@code Level}. + * + * @param block The block of the house. + * @param level The level of the house. + * @param postalCode The postal code of the house. + * @param street The street of the house. + * @param unitNumber The unit number of the house. + */ + public NonLanded(Block block, Level level, PostalCode postalCode, Street street, UnitNumber unitNumber) { + super(unitNumber, postalCode, street); + this.block = block; + this.level = level; + this.unitNumber = unitNumber; + } + + /** + * Constructs a {@code Level}. + * + * @param level The level of the house. + * @param postalCode The postal code of the house. + * @param street The street of the house. + * @param unitNumber The unit number of the house. + */ + public NonLanded(Level level, PostalCode postalCode, Street street, UnitNumber unitNumber) { + super(unitNumber, postalCode, street); + this.block = null; + this.level = level; + this.unitNumber = unitNumber; + } } diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 6af0032e849..0906197c57d 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -8,6 +8,7 @@ import java.util.Set; import seedu.address.commons.util.ToStringBuilder; +import seedu.address.model.house.House; import seedu.address.model.house.PostalCode; import seedu.address.model.tag.Tag; @@ -23,19 +24,19 @@ public class Person { private final Email email; // Data fields - private final Address address; + private final House house; private final PostalCode postalCode; private final Set tags = new HashSet<>(); /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Address address, PostalCode postalCode, Set tags) { - requireAllNonNull(name, phone, email, address, tags); + public Person(Name name, Phone phone, Email email, House house, PostalCode postalCode, Set tags) { + requireAllNonNull(name, phone, email, house, tags); this.name = name; this.phone = phone; this.email = email; - this.address = address; + this.house = house; this.postalCode = postalCode; this.tags.addAll(tags); } @@ -52,8 +53,8 @@ public Email getEmail() { return email; } - public Address getAddress() { - return address; + public House getHouse() { + return house; } public PostalCode getPostalCode() { @@ -100,7 +101,7 @@ public boolean equals(Object other) { return name.equals(otherPerson.name) && phone.equals(otherPerson.phone) && email.equals(otherPerson.email) - && address.equals(otherPerson.address) + && house.equals(otherPerson.house) && postalCode.equals(otherPerson.postalCode) && tags.equals(otherPerson.tags); } @@ -108,7 +109,7 @@ public boolean equals(Object other) { @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, address, postalCode, tags); + return Objects.hash(name, phone, email, house, postalCode, tags); } @Override @@ -117,7 +118,7 @@ public String toString() { .add("name", name) .add("phone", phone) .add("email", email) - .add("address", address) + .add("address", house) .add("postal code", postalCode) .add("tags", tags) .toString(); diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index abb1faddc06..9c9dd459fc0 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -35,7 +35,7 @@ public class PersonCard extends UiPart { @FXML private Label phone; @FXML - private Label address; + private Label house; @FXML private Label email; @FXML @@ -52,7 +52,7 @@ public PersonCard(Person person, int displayedIndex) { id.setText(displayedIndex + ". "); name.setText(person.getName().fullName); phone.setText(person.getPhone().value); - address.setText(person.getAddress().value); + house.setText(person.getHouse().toString()); email.setText(person.getEmail().value); postalCode.setText("S" + person.getPostalCode().value); person.getTags().stream() diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index 4584bd5044e..54bc142425c 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -5,6 +5,7 @@ import java.util.stream.Stream; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.model.house.House; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -35,7 +36,7 @@ public EditPersonDescriptorBuilder(Person person) { descriptor.setName(person.getName()); descriptor.setPhone(person.getPhone()); descriptor.setEmail(person.getEmail()); - descriptor.setAddress(person.getAddress()); + descriptor.setHouse(person.getHouse()); descriptor.setTags(person.getTags()); } @@ -66,8 +67,8 @@ public EditPersonDescriptorBuilder withEmail(String email) { /** * Sets the {@code Address} of the {@code EditPersonDescriptor} that we are building. */ - public EditPersonDescriptorBuilder withAddress(String address) { - descriptor.setAddress(new Address(address)); + public EditPersonDescriptorBuilder withHouse(String house) { + descriptor.setHouse(new House(house)); return this; } From 80b686294ebee68decc6e932ab4fc4451e3f266e Mon Sep 17 00:00:00 2001 From: redcolorbicycle Date: Mon, 18 Mar 2024 11:38:03 +0800 Subject: [PATCH 03/34] implement house structure and logic, half replace address with individual components --- .../logic/commands/AddBuyerCommand.java | 14 ++-- .../logic/commands/AddSellerCommand.java | 20 +++--- .../logic/parser/AddBuyerCommandParser.java | 20 ++---- .../logic/parser/AddSellerCommandParser.java | 64 +++++++++++++------ .../logic/parser/AddressBookParser.java | 3 - .../seedu/address/logic/parser/CliSyntax.java | 1 - .../logic/parser/EditCommandParser.java | 12 ++-- .../address/logic/parser/ParserUtil.java | 3 +- .../java/seedu/address/model/house/House.java | 16 ++++- .../seedu/address/model/person/Buyer.java | 24 ++++--- .../seedu/address/model/person/Person.java | 25 +++----- .../seedu/address/model/person/Seller.java | 30 ++++++--- 12 files changed, 137 insertions(+), 95 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddBuyerCommand.java b/src/main/java/seedu/address/logic/commands/AddBuyerCommand.java index 6a9e6b07e8d..72348244165 100644 --- a/src/main/java/seedu/address/logic/commands/AddBuyerCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddBuyerCommand.java @@ -1,12 +1,8 @@ package seedu.address.logic.commands; 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_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_POSTALCODE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; +import static seedu.address.logic.parser.CliSyntax.PREFIX_UNITNUMBER; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; @@ -26,15 +22,13 @@ public class AddBuyerCommand extends Command { + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " - + PREFIX_ADDRESS + "ADDRESS " - + PREFIX_POSTALCODE + "POSTAL CODE " + + PREFIX_HOUSINGTYPE + "HOUSINGTYPE" + "[" + 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_POSTALCODE + "578578 " + + PREFIX_HOUSINGTYPE + "HDB " + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; diff --git a/src/main/java/seedu/address/logic/commands/AddSellerCommand.java b/src/main/java/seedu/address/logic/commands/AddSellerCommand.java index 3ee309bcad5..3f399fbb800 100644 --- a/src/main/java/seedu/address/logic/commands/AddSellerCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddSellerCommand.java @@ -1,12 +1,8 @@ package seedu.address.logic.commands; 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_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_POSTALCODE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; +import static seedu.address.logic.parser.CliSyntax.PREFIX_UNITNUMBER; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; @@ -26,14 +22,22 @@ public class AddSellerCommand extends Command { + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " - + PREFIX_ADDRESS + "ADDRESS " + + PREFIX_HOUSINGTYPE + "HOUSINGTYPE" + + PREFIX_STREET + "STREET " + + PREFIX_BLOCK + "BLOCK " + + PREFIX_LEVEL + "LEVEL " + + PREFIX_UNITNUMBER + "UNITNUMBER " + PREFIX_POSTALCODE + "POSTAL CODE " + "[" + 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_HOUSINGTYPE + "HDB " + + PREFIX_STREET + "Clementi Ave 2 " + + PREFIX_BLOCK + "Block 311 " + + PREFIX_LEVEL + "Level 02" + + PREFIX_UNITNUMBER + "Unit 25" + PREFIX_POSTALCODE + "578578 " + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; diff --git a/src/main/java/seedu/address/logic/parser/AddBuyerCommandParser.java b/src/main/java/seedu/address/logic/parser/AddBuyerCommandParser.java index 1ca99c3c9e6..9a84eee077b 100644 --- a/src/main/java/seedu/address/logic/parser/AddBuyerCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddBuyerCommandParser.java @@ -1,12 +1,7 @@ package seedu.address.logic.parser; import static seedu.address.logic.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_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_POSTALCODE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; import java.util.Set; import java.util.stream.Stream; @@ -33,24 +28,23 @@ public class AddBuyerCommandParser implements Parser { */ public AddBuyerCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, - PREFIX_POSTALCODE, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_HOUSINGTYPE, + PREFIX_TAG); - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_POSTALCODE) + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_HOUSINGTYPE) || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddBuyerCommand.MESSAGE_USAGE)); } argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, - PREFIX_ADDRESS, PREFIX_POSTALCODE); + PREFIX_HOUSINGTYPE, PREFIX_TAG); Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); 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()); - PostalCode postalCode = ParserUtil.parsePostalCode(argMultimap.getValue(PREFIX_POSTALCODE).get()); + String housingtype = ParserUtil.parseHousing(argMultimap.getValue(PREFIX_HOUSINGTYPE).get()); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - Person person = new Person(name, phone, email, address, postalCode, tagList); + Person person = new Person(name, phone, email, housingtype, tagList); return new AddBuyerCommand(person); } diff --git a/src/main/java/seedu/address/logic/parser/AddSellerCommandParser.java b/src/main/java/seedu/address/logic/parser/AddSellerCommandParser.java index 16ab89c527f..e523b822ad2 100644 --- a/src/main/java/seedu/address/logic/parser/AddSellerCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddSellerCommandParser.java @@ -1,24 +1,17 @@ package seedu.address.logic.parser; import static seedu.address.logic.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_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_POSTALCODE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; +import static seedu.address.logic.parser.CliSyntax.PREFIX_LEVEL; import java.util.Set; import java.util.stream.Stream; +import seedu.address.logic.commands.AddCommand; import seedu.address.logic.commands.AddSellerCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.house.PostalCode; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.house.*; +import seedu.address.model.person.*; import seedu.address.model.tag.Tag; /** @@ -32,25 +25,56 @@ public class AddSellerCommandParser implements Parser { * @throws ParseException if the user input does not conform the expected format */ public AddSellerCommand parse(String args) throws ParseException { + boolean HASBLOCK = true; + boolean HASLEVEL = true; ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, - PREFIX_POSTALCODE, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_HOUSINGTYPE, PREFIX_LEVEL, + PREFIX_EMAIL, PREFIX_BLOCK, PREFIX_STREET, PREFIX_UNITNUMBER, PREFIX_POSTALCODE, PREFIX_TAG); - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_POSTALCODE) + + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_HOUSINGTYPE, + PREFIX_POSTALCODE, PREFIX_STREET, PREFIX_UNITNUMBER, PREFIX_TAG) || !argMultimap.getPreamble().isEmpty()) { - throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddSellerCommand.MESSAGE_USAGE)); + throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, - PREFIX_ADDRESS, PREFIX_POSTALCODE); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_HOUSINGTYPE, PREFIX_LEVEL, + PREFIX_EMAIL, PREFIX_BLOCK, PREFIX_STREET, PREFIX_UNITNUMBER, PREFIX_POSTALCODE); Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); 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()); + UnitNumber unitNumber = ParserUtil.parseUnitNumber(argMultimap.getValue(PREFIX_UNITNUMBER).get()); PostalCode postalCode = ParserUtil.parsePostalCode(argMultimap.getValue(PREFIX_POSTALCODE).get()); + Street street = ParserUtil.parseStreet(argMultimap.getValue(PREFIX_STREET).get()); + String housingtype = ParserUtil.parseHousing(argMultimap.getValue(PREFIX_HOUSINGTYPE).get()); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - Person person = new Person(name, phone, email, address, postalCode, tagList); + //NonLandeds might not have blocks, Landeds definitely do not have blocks. + if (!argMultimap.getValue(PREFIX_BLOCK).isPresent()) { + HASBLOCK = false; + } + + //Landeds do not have levels + if (!argMultimap.getValue(PREFIX_BLOCK).isPresent()) { + HASLEVEL = false; + } + + if (HASLEVEL && HASBLOCK) { + Block block = ParserUtil.parseBlock(argMultimap.getValue(PREFIX_BLOCK).get()); + Level level = ParserUtil.parseLevel(argMultimap.getValue(PREFIX_LEVEL).get()); + House house = new NonLanded(block, level, postalCode, street, unitNumber); + Person person = new Seller(name, phone, email, housingtype, house, street, postalCode, unitNumber, tagList); + return new AddSellerCommand(person); + } else if (HASLEVEL) { + Level level = ParserUtil.parseLevel(argMultimap.getValue(PREFIX_LEVEL).get()); + House house = new NonLanded(level, postalCode, street, unitNumber); + Person person = new Seller(name, phone, email, housingtype, house, street, postalCode, unitNumber, tagList); + return new AddSellerCommand(person); + } + + House house = new Landed(unitNumber, postalCode, street); + + Person person = new Seller(name, phone, email, housingtype, house, street, postalCode, unitNumber, tagList); return new AddSellerCommand(person); } diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 53a2e72787f..8147185c1ce 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -55,9 +55,6 @@ public Command parseCommand(String userInput) throws ParseException { switch (commandWord) { - case AddCommand.COMMAND_WORD: - return new AddCommandParser().parse(arguments); - case AddSellerCommand.COMMAND_WORD: return new AddSellerCommandParser().parse(arguments); diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 0b9b96b8a20..d5d0b2c217b 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -9,7 +9,6 @@ public class CliSyntax { public static final Prefix PREFIX_NAME = new Prefix("n/"); 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_TAG = new Prefix("t/"); public static final Prefix PREFIX_HOUSINGTYPE = new Prefix("type/"); public static final Prefix PREFIX_STREET = new Prefix("street/"); diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index dc422732c37..da941c742d1 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -2,7 +2,7 @@ import static java.util.Objects.requireNonNull; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; +import static seedu.address.logic.parser.CliSyntax.PREFIX_HOUSINGTYPE; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -32,17 +32,19 @@ 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_HOUSINGTYPE, + PREFIX_TAG); Index index; try { index = ParserUtil.parseIndex(argMultimap.getPreamble()); + } catch (ParseException pe) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_HOUSINGTYPE); EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); @@ -55,9 +57,7 @@ public EditCommand parse(String args) throws ParseException { if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) { editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get())); } - if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) { - editPersonDescriptor.setHouse(ParserUtil.parseHousing(argMultimap.getValue(PREFIX_HOUSE).get())); - } + parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags); if (!editPersonDescriptor.isAnyFieldEdited()) { diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index d8ddcfb3f6b..0090d01d4c0 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -137,12 +137,13 @@ public static Set parseTags(Collection tags) throws ParseException * * @throws ParseException if the given {@code street} is invalid. */ - public static void parseHousing(String name) throws ParseException { + public static String parseHousing(String name) throws ParseException { requireNonNull(name); String trimmedName = name.trim(); if (!House.isValidName(trimmedName.toLowerCase())) { throw new ParseException(House.MESSAGE_CONSTRAINTS); } + return trimmedName; } /** diff --git a/src/main/java/seedu/address/model/house/House.java b/src/main/java/seedu/address/model/house/House.java index 598300cc4be..4a0aa768fa0 100644 --- a/src/main/java/seedu/address/model/house/House.java +++ b/src/main/java/seedu/address/model/house/House.java @@ -70,8 +70,22 @@ public static boolean isValidName(String name) { return false; } + public boolean equals(Object other) { + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof House)) { + return false; + } + + House otherStreet = (House) other; + return this.toString().equals(other.toString()); + } + public String toString() { - return "HOMELESS"; + return "House"; } diff --git a/src/main/java/seedu/address/model/person/Buyer.java b/src/main/java/seedu/address/model/person/Buyer.java index 62ac8cca5f2..c65d36d4265 100644 --- a/src/main/java/seedu/address/model/person/Buyer.java +++ b/src/main/java/seedu/address/model/person/Buyer.java @@ -2,6 +2,7 @@ import java.util.Set; +import seedu.address.model.house.House; import seedu.address.model.house.PostalCode; import seedu.address.model.tag.Tag; /** @@ -9,18 +10,25 @@ */ public class Buyer extends Person { + private final House house; + /** * Constructs a new Buyer instance. * - * @param name The name of the buyer. - * @param phone The phone number of the buyer. - * @param email The email address of the buyer. - * @param address The address of the buyer. - * @param postalCode The postal code of the buyer's address. - * @param tags The tags associated with the buyer. + * @param name The name of the buyer. + * @param phone The phone number of the buyer. + * @param email The email address of the buyer. + * @param housingtype The type of housing the buyer wants. + * @param tags The tags associated with the buyer. */ - public Buyer(Name name, Phone phone, Email email, Address address, PostalCode postalCode, Set tags) { - super(name, phone, email, address, postalCode, tags); + public Buyer(Name name, Phone phone, Email email, String housingtype, Set tags) { + super(name, phone, email, housingtype, tags); + this.house = null; + } + + public Buyer(Name name, Phone phone, Email email, String housingtype, House house, Set tags) { + super(name, phone, email, housingtype, tags); + this.house = house; } } diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 0906197c57d..122f15e0c37 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -23,21 +23,19 @@ public class Person { private final Phone phone; private final Email email; - // Data fields - private final House house; - private final PostalCode postalCode; + // critically, this refers to what type the buyer WANTS, and what type the seller HAS + private final String housingtype; private final Set tags = new HashSet<>(); /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, House house, PostalCode postalCode, Set tags) { + public Person(Name name, Phone phone, Email email, String house, Set tags) { requireAllNonNull(name, phone, email, house, tags); this.name = name; this.phone = phone; this.email = email; - this.house = house; - this.postalCode = postalCode; + this.housingtype = house; this.tags.addAll(tags); } @@ -53,13 +51,10 @@ public Email getEmail() { return email; } - public House getHouse() { - return house; + public String getHouse() { + return housingtype; } - public PostalCode getPostalCode() { - return postalCode; - } /** * Returns an immutable tag set, which throws {@code UnsupportedOperationException} @@ -101,15 +96,14 @@ public boolean equals(Object other) { return name.equals(otherPerson.name) && phone.equals(otherPerson.phone) && email.equals(otherPerson.email) - && house.equals(otherPerson.house) - && postalCode.equals(otherPerson.postalCode) + && housingtype.equals(otherPerson.housingtype) && tags.equals(otherPerson.tags); } @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, house, postalCode, tags); + return Objects.hash(name, phone, email, housingtype, tags); } @Override @@ -118,8 +112,7 @@ public String toString() { .add("name", name) .add("phone", phone) .add("email", email) - .add("address", house) - .add("postal code", postalCode) + .add("address", housingtype) .add("tags", tags) .toString(); } diff --git a/src/main/java/seedu/address/model/person/Seller.java b/src/main/java/seedu/address/model/person/Seller.java index 66b4012a841..7363e11b939 100644 --- a/src/main/java/seedu/address/model/person/Seller.java +++ b/src/main/java/seedu/address/model/person/Seller.java @@ -2,7 +2,10 @@ import java.util.Set; +import seedu.address.model.house.House; import seedu.address.model.house.PostalCode; +import seedu.address.model.house.Street; +import seedu.address.model.house.UnitNumber; import seedu.address.model.tag.Tag; /** @@ -10,17 +13,28 @@ */ public class Seller extends Person { + private final Street street; + private final House house; + private final PostalCode postalCode; + private final UnitNumber unitNumber; + /** * Constructs a new Seller instance. * - * @param name The name of the seller. - * @param phone The phone number of the seller. - * @param email The email address of the seller. - * @param address The address of the seller. - * @param postalCode The postal code of the seller's address. - * @param tags The tags associated with the seller. + * @param name The name of the seller. + * @param phone The phone number of the seller. + * @param email The email address of the seller. + * @param housingtype The housing type the seller has + * @param street The street of the seller's house + * @param postalCode The postal code of the seller's address. + * @param tags The tags associated with the seller. */ - public Seller(Name name, Phone phone, Email email, Address address, PostalCode postalCode, Set tags) { - super(name, phone, email, address, postalCode, tags); + public Seller(Name name, Phone phone, Email email, String housingtype, House house, Street street, + PostalCode postalCode, UnitNumber unitNumber, Set tags) { + super(name, phone, email, housingtype, tags); + this.house = house; + this.street = street; + this.postalCode = postalCode; + this.unitNumber = unitNumber; } } From 74a314b8f63a63125818adb14e5a0b4143b79d3f Mon Sep 17 00:00:00 2001 From: redcolorbicycle Date: Mon, 18 Mar 2024 12:00:26 +0800 Subject: [PATCH 04/34] implement house structure and logic, half replace address with individual components --- .../java/seedu/address/logic/Messages.java | 6 +- .../address/logic/commands/EditCommand.java | 5 +- .../logic/parser/AddCommandParser.java | 90 ------------------- .../seedu/address/model/person/Person.java | 2 +- .../address/storage/JsonAdaptedPerson.java | 30 ++----- .../java/seedu/address/ui/PersonCard.java | 3 +- .../testutil/EditPersonDescriptorBuilder.java | 8 -- 7 files changed, 16 insertions(+), 128 deletions(-) delete mode 100644 src/main/java/seedu/address/logic/parser/AddCommandParser.java diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index 8d48e45a986..9c29200c9b9 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -41,10 +41,8 @@ public static String format(Person person) { .append(person.getPhone()) .append("; Email: ") .append(person.getEmail()) - .append("; Address: ") - .append(person.getAddress()) - .append("; Postal Code: ") - .append(person.getPostalCode()) + .append("; Housing Type: ") + .append(person.getHousingType()) .append("; Tags: "); person.getTags().forEach(builder::append); return builder.toString(); diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index b26f378ed07..a6be8a1f4ef 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -1,7 +1,6 @@ package seedu.address.logic.commands; 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_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -21,7 +20,7 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; -import seedu.address.model.house.House; +import seedu.address.model.house.*; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; @@ -99,11 +98,13 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); + /* Street updatedStreet = editPersonDescriptor.getStreet().orElse(personToEdit.getStreet()); Level updatedLevel = editPersonDescriptor.getLevel().orElse(personToEdit.getLevel()); Block updatedBlock = editPersonDescriptor.getBlock().orElse(personToEdit.getBlock()); UnitNumber unitNumber = editPersonDescriptor.getUnitNumber().orElse(personToEdit.getUnitNumber()); PostalCode postalCode = editPersonDescriptor.getPostalCode().orElse(personToEdit.getPostalCode()); + */ Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); return new Person(updatedName, updatedPhone, updatedEmail, updatedHouse, diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java deleted file mode 100644 index 7a1e07d5e0d..00000000000 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ /dev/null @@ -1,90 +0,0 @@ -package seedu.address.logic.parser; - -import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.*; - -import java.util.Set; -import java.util.stream.Stream; - -import seedu.address.logic.commands.AddCommand; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.house.*; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; -import seedu.address.model.tag.Tag; - -/** - * Parses input arguments and creates a new AddCommand object - */ -public class AddCommandParser implements Parser { - - /** - * Parses the given {@code String} of arguments in the context of the AddCommand - * and returns an AddCommand object for execution. - * @throws ParseException if the user input does not conform the expected format - */ - public AddCommand parse(String args) throws ParseException { - boolean HASBLOCK = true; - boolean HASLEVEL = true; - ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_HOUSINGTYPE, PREFIX_LEVEL, - PREFIX_EMAIL, PREFIX_BLOCK, PREFIX_STREET, PREFIX_UNITNUMBER, PREFIX_POSTALCODE, PREFIX_TAG); - - //include more here for buyer/seller? - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL) - || !argMultimap.getPreamble().isEmpty()) { - throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); - } - - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_HOUSINGTYPE, PREFIX_LEVEL, - PREFIX_EMAIL, PREFIX_BLOCK, PREFIX_STREET, PREFIX_UNITNUMBER, PREFIX_POSTALCODE); - Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); - Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); - Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); - UnitNumber unitNumber = ParserUtil.parseUnitNumber(argMultimap.getValue(PREFIX_UNITNUMBER).get()); - PostalCode postalCode = ParserUtil.parsePostalCode(argMultimap.getValue(PREFIX_POSTALCODE).get()); - Street street = ParserUtil.parseStreet(argMultimap.getValue(PREFIX_STREET).get()); - Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - - //NonLandeds might not have blocks, Landeds definitely do not have blocks. - if (!argMultimap.getValue(PREFIX_BLOCK).isPresent()) { - HASBLOCK = false; - } - - //Landeds do not have levels - if (!argMultimap.getValue(PREFIX_BLOCK).isPresent()) { - HASLEVEL = false; - } - - if (HASLEVEL && HASBLOCK) { - Block block = ParserUtil.parseBlock(argMultimap.getValue(PREFIX_BLOCK).get()); - Level level = ParserUtil.parseLevel(argMultimap.getValue(PREFIX_LEVEL).get()); - House house = new NonLanded(block, level, postalCode, street, unitNumber); - Person person = new Person(name, phone, email, house, postalCode, tagList); - return new AddCommand(person); - } else if (HASLEVEL) { - Level level = ParserUtil.parseLevel(argMultimap.getValue(PREFIX_LEVEL).get()); - House house = new NonLanded(level, postalCode, street, unitNumber); - Person person = new Person(name, phone, email, house, postalCode, tagList); - return new AddCommand(person); - } - - House house = new Landed(unitNumber, postalCode, street); - - Person person = new Person(name, phone, email, house, postalCode, tagList); - - return new AddCommand(person); - } - - /** - * Returns true if none of the prefixes contains empty {@code Optional} values in the given - * {@code ArgumentMultimap}. - */ - private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { - return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); - } - -} diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 122f15e0c37..69f634d110c 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -51,7 +51,7 @@ public Email getEmail() { return email; } - public String getHouse() { + public String getHousingType() { return housingtype; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index 3683e183718..ea9575d08d0 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.house.House; import seedu.address.model.house.PostalCode; import seedu.address.model.person.Address; import seedu.address.model.person.Email; @@ -28,8 +29,7 @@ class JsonAdaptedPerson { private final String name; private final String phone; private final String email; - private final String address; - private final String postalCode; + private final String housingtype; private final List tags = new ArrayList<>(); /** @@ -37,14 +37,13 @@ class JsonAdaptedPerson { */ @JsonCreator public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone, - @JsonProperty("email") String email, @JsonProperty("address") String address, + @JsonProperty("email") String email, @JsonProperty("housingType") String housingtype, @JsonProperty("postalCode") String postalCode, @JsonProperty("tags") List tags) { this.name = name; this.phone = phone; this.email = email; - this.address = address; - this.postalCode = postalCode; + this.housingtype = housingtype; if (tags != null) { this.tags.addAll(tags); } @@ -57,8 +56,7 @@ public JsonAdaptedPerson(Person source) { name = source.getName().fullName; phone = source.getPhone().value; email = source.getEmail().value; - address = source.getAddress().value; - postalCode = source.getPostalCode().value; + housingtype = source.getHousingType(); tags.addAll(source.getTags().stream() .map(JsonAdaptedTag::new) .collect(Collectors.toList())); @@ -99,25 +97,15 @@ public Person toModelType() throws IllegalValueException { } final Email modelEmail = new Email(email); - if (address == null) { + if (housingtype == null) { throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName())); } - if (!Address.isValidAddress(address)) { - throw new IllegalValueException(Address.MESSAGE_CONSTRAINTS); + if (!House.isValidName(housingtype)) { + throw new IllegalValueException(House.MESSAGE_CONSTRAINTS); } - final Address modelAddress = new Address(address); - - if (postalCode == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, - PostalCode.class.getSimpleName())); - } - if (!PostalCode.isValidPostalCode(postalCode)) { - throw new IllegalValueException(PostalCode.MESSAGE_CONSTRAINTS); - } - final PostalCode modelPostalCode = new PostalCode(postalCode); final Set modelTags = new HashSet<>(personTags); - return new Person(modelName, modelPhone, modelEmail, modelAddress, modelPostalCode, modelTags); + return new Person(modelName, modelPhone, modelEmail, housingtype, modelTags); } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 9c9dd459fc0..314b748f791 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -52,9 +52,8 @@ public PersonCard(Person person, int displayedIndex) { id.setText(displayedIndex + ". "); name.setText(person.getName().fullName); phone.setText(person.getPhone().value); - house.setText(person.getHouse().toString()); + house.setText(person.getHousingType()); email.setText(person.getEmail().value); - postalCode.setText("S" + person.getPostalCode().value); person.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index 54bc142425c..269c1e017b9 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -36,7 +36,6 @@ public EditPersonDescriptorBuilder(Person person) { descriptor.setName(person.getName()); descriptor.setPhone(person.getPhone()); descriptor.setEmail(person.getEmail()); - descriptor.setHouse(person.getHouse()); descriptor.setTags(person.getTags()); } @@ -64,13 +63,6 @@ public EditPersonDescriptorBuilder withEmail(String email) { return this; } - /** - * Sets the {@code Address} of the {@code EditPersonDescriptor} that we are building. - */ - public EditPersonDescriptorBuilder withHouse(String house) { - descriptor.setHouse(new House(house)); - return this; - } /** * Parses the {@code tags} into a {@code Set} and set it to the {@code EditPersonDescriptor} From ffb1b3a81114902c9c197c2c4de79b0f0f2f9baf Mon Sep 17 00:00:00 2001 From: redcolorbicycle Date: Mon, 18 Mar 2024 12:30:56 +0800 Subject: [PATCH 05/34] implement house structure and logic, half replace address with individual components --- .../address/logic/commands/EditCommand.java | 22 +++++++++---------- .../address/model/util/SampleDataUtil.java | 12 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index a6be8a1f4ef..0b0603bf6f6 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -42,7 +42,6 @@ public class EditCommand extends Command { + "[" + PREFIX_NAME + "NAME] " + "[" + PREFIX_PHONE + "PHONE] " + "[" + PREFIX_EMAIL + "EMAIL] " - + "[" + PREFIX_ADDRESS + "ADDRESS] " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " 1 " + PREFIX_PHONE + "91234567 " @@ -98,6 +97,7 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); + String updatedHouse = editPersonDescriptor.getHousingType().orElse(personToEdit.getHousingType()); /* Street updatedStreet = editPersonDescriptor.getStreet().orElse(personToEdit.getStreet()); Level updatedLevel = editPersonDescriptor.getLevel().orElse(personToEdit.getLevel()); @@ -108,7 +108,7 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); return new Person(updatedName, updatedPhone, updatedEmail, updatedHouse, - personToEdit.getPostalCode(), updatedTags); + updatedTags); } @Override @@ -143,7 +143,7 @@ public static class EditPersonDescriptor { private Name name; private Phone phone; private Email email; - private House house; + private String housingtype; private Set tags; public EditPersonDescriptor() { @@ -157,7 +157,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setName(toCopy.name); setPhone(toCopy.phone); setEmail(toCopy.email); - setHouse(toCopy.house); + setHousingType(toCopy.housingtype); setTags(toCopy.tags); } @@ -166,7 +166,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(name, phone, email, address, tags); + return CollectionUtil.isAnyNonNull(name, phone, email, housingtype, tags); } public void setName(Name name) { @@ -193,12 +193,12 @@ public Optional getEmail() { return Optional.ofNullable(email); } - public void setHouse(House house) { - this.house = house; + public void setHousingType(String housingtype) { + this.housingtype = housingtype; } - public Optional getHouse() { - return Optional.ofNullable(house); + public Optional getHousingType() { + return Optional.ofNullable(housingtype); } /** @@ -233,7 +233,7 @@ public boolean equals(Object other) { return Objects.equals(name, otherEditPersonDescriptor.name) && Objects.equals(phone, otherEditPersonDescriptor.phone) && Objects.equals(email, otherEditPersonDescriptor.email) - && Objects.equals(address, otherEditPersonDescriptor.address) + && Objects.equals(housingtype, otherEditPersonDescriptor.housingtype) && Objects.equals(tags, otherEditPersonDescriptor.tags); } @@ -243,7 +243,7 @@ public String toString() { .add("name", name) .add("phone", phone) .add("email", email) - .add("address", address) + .add("housingtype", housingtype) .add("tags", tags) .toString(); } diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 526f7cf0a38..7a954698732 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -21,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 PostalCode("123456"), + "HDB", 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 PostalCode("123567"), + "Condominium", 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 PostalCode("123890"), + "HDB", 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 PostalCode("123123"), + "HDB", 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 PostalCode("123010"), + "HDB", 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 PostalCode("123787"), + "HDB", getTagSet("colleagues")) }; } From 8501f64a3d05b86c49b46a11a8d91316e98a7d7a Mon Sep 17 00:00:00 2001 From: redcolorbicycle Date: Mon, 18 Mar 2024 13:22:18 +0800 Subject: [PATCH 06/34] implement house structure and logic, half replace address with individual components --- src/main/java/seedu/address/logic/commands/AddCommand.java | 6 +++--- .../seedu/address/logic/parser/AddBuyerCommandParser.java | 2 +- .../seedu/address/logic/parser/AddSellerCommandParser.java | 2 +- src/main/java/seedu/address/ui/PersonCard.java | 4 ++-- src/main/resources/view/PersonListCard.fxml | 2 +- 5 files changed, 8 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 89b4b9fbcf7..3af14468072 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -34,9 +34,9 @@ public class AddCommand extends Command { + PREFIX_EMAIL + "johnd@example.com " + PREFIX_HOUSINGTYPE + "HDB " + PREFIX_STREET + "Clementi Ave 2 " - + PREFIX_BLOCK + "Block 311 " - + PREFIX_LEVEL + "Level 02" - + PREFIX_UNITNUMBER + "Unit 25" + + PREFIX_BLOCK + "311 " + + PREFIX_LEVEL + "02 " + + PREFIX_UNITNUMBER + "25 " + PREFIX_POSTALCODE + "578578 " + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; diff --git a/src/main/java/seedu/address/logic/parser/AddBuyerCommandParser.java b/src/main/java/seedu/address/logic/parser/AddBuyerCommandParser.java index 9a84eee077b..8ba3af512ff 100644 --- a/src/main/java/seedu/address/logic/parser/AddBuyerCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddBuyerCommandParser.java @@ -37,7 +37,7 @@ public AddBuyerCommand parse(String args) throws ParseException { } argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, - PREFIX_HOUSINGTYPE, PREFIX_TAG); + PREFIX_HOUSINGTYPE); Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); diff --git a/src/main/java/seedu/address/logic/parser/AddSellerCommandParser.java b/src/main/java/seedu/address/logic/parser/AddSellerCommandParser.java index e523b822ad2..54187e21c52 100644 --- a/src/main/java/seedu/address/logic/parser/AddSellerCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddSellerCommandParser.java @@ -33,7 +33,7 @@ public AddSellerCommand parse(String args) throws ParseException { if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_HOUSINGTYPE, - PREFIX_POSTALCODE, PREFIX_STREET, PREFIX_UNITNUMBER, PREFIX_TAG) + PREFIX_POSTALCODE, PREFIX_STREET, PREFIX_UNITNUMBER) || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 314b748f791..c2018331ef5 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -35,7 +35,7 @@ public class PersonCard extends UiPart { @FXML private Label phone; @FXML - private Label house; + private Label housingtype; @FXML private Label email; @FXML @@ -52,7 +52,7 @@ public PersonCard(Person person, int displayedIndex) { id.setText(displayedIndex + ". "); name.setText(person.getName().fullName); phone.setText(person.getPhone().value); - house.setText(person.getHousingType()); + housingtype.setText(person.getHousingType()); email.setText(person.getEmail().value); person.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index f45af7b065b..5e0baa17a55 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -29,8 +29,8 @@