Skip to content

Commit

Permalink
Merge pull request #1 from KhoonSun47/branch-add-seller-1
Browse files Browse the repository at this point in the history
Branch-add-seller
  • Loading branch information
KhoonSun47 authored Mar 20, 2024
2 parents 2d7f55b + 5de956e commit 335bd2c
Show file tree
Hide file tree
Showing 40 changed files with 572 additions and 604 deletions.
6 changes: 2 additions & 4 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
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_HOUSINGTYPE;
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 seedu.address.commons.util.ToStringBuilder;
Expand All @@ -26,15 +25,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";

Expand Down
20 changes: 16 additions & 4 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
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_BLOCK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_HOUSINGTYPE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LEVEL;
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_STREET;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_UNITNUMBER;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
Expand All @@ -15,7 +19,7 @@
import seedu.address.model.person.Person;

/**
* Adds a person to the address book.
* Adds a person to the address book. Currently obsolete
*/
public class AddCommand extends Command {

Expand All @@ -26,14 +30,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 + "311 "
+ PREFIX_LEVEL + "02 "
+ PREFIX_UNITNUMBER + "25 "
+ PREFIX_POSTALCODE + "578578 "
+ PREFIX_TAG + "friends "
+ PREFIX_TAG + "owesMoney";
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/seedu/address/logic/commands/AddSellerCommand.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
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_BLOCK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_HOUSINGTYPE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LEVEL;
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_STREET;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_UNITNUMBER;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
Expand All @@ -26,14 +30,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";
Expand Down
35 changes: 20 additions & 15 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,7 +20,6 @@
import seedu.address.logic.Messages;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
Expand All @@ -42,7 +40,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 "
Expand Down Expand Up @@ -98,11 +95,18 @@ 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());
String updatedHouse = editPersonDescriptor.getHousingType().orElse(personToEdit.getHousingType());
/*
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<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());

return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress,
personToEdit.getPostalCode(), updatedTags);
return new Person(updatedName, updatedPhone, updatedEmail, updatedHouse,
updatedTags);
}

@Override
Expand Down Expand Up @@ -137,7 +141,7 @@ public static class EditPersonDescriptor {
private Name name;
private Phone phone;
private Email email;
private Address address;
private String housingType;
private Set<Tag> tags;

public EditPersonDescriptor() {
Expand All @@ -151,15 +155,16 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setName(toCopy.name);
setPhone(toCopy.phone);
setEmail(toCopy.email);
setAddress(toCopy.address);
setHousingType(toCopy.housingType);
setTags(toCopy.tags);
}


/**
* 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) {
Expand All @@ -186,12 +191,12 @@ public Optional<Email> getEmail() {
return Optional.ofNullable(email);
}

public void setAddress(Address address) {
this.address = address;
public void setHousingType(String housingType) {
this.housingType = housingType;
}

public Optional<Address> getAddress() {
return Optional.ofNullable(address);
public Optional<String> getHousingType() {
return Optional.ofNullable(housingType);
}

/**
Expand Down Expand Up @@ -226,7 +231,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);
}

Expand All @@ -236,7 +241,7 @@ public String toString() {
.add("name", name)
.add("phone", phone)
.add("email", email)
.add("address", address)
.add("housingType", housingType)
.add("tags", tags)
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +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_HOUSINGTYPE;
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 java.util.Set;
import java.util.stream.Stream;

import seedu.address.logic.commands.AddBuyerCommand;
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;
Expand All @@ -33,24 +30,23 @@ public class AddBuyerCommandParser implements Parser<AddBuyerCommand> {
*/
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);
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<Tag> 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);
}
Expand Down
66 changes: 0 additions & 66 deletions src/main/java/seedu/address/logic/parser/AddCommandParser.java

This file was deleted.

Loading

0 comments on commit 335bd2c

Please sign in to comment.