Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
lrongyi committed Nov 7, 2024
2 parents 3d2b0e8 + acb7c2d commit b3863c9
Show file tree
Hide file tree
Showing 27 changed files with 263 additions and 290 deletions.
34 changes: 17 additions & 17 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,21 @@ The prefixes used in EZSTATES are universal across all commands <br> _(i.e. have
</div>
<br>

| Prefix | Meaning | Location | Constraints | Remarks | Example |
|----------|---------|-------------|-------------|---------|---------|
| n/ | name | Client | | | |
| p/ | phone | Client | | | |
| e/ | email | Client | | | |
| t/ | tag | Client | | | |
| d/ | date | Appointment | | | |
| fr/ | from | Appointment | | | |
| to/ | to | Appointment | | | |
| price/ | price | Listing | | | |
| area/ | area | Listing | | | |
| address/ | address | Listing | | | |
| region/ | region | Listing | | | |
| seller/ | seller | Listing | | | |
| buyer/ | buyer | Listing | | | |
| Prefix | Meaning | Location | Constraints | Remarks | Example |
|--------|---------|-------------|-------------|---------|---------|
| n/ | name | Client | | | |
| p/ | phone | Client | | | |
| e/ | email | Client | | | |
| t/ | tag | Client | | | |
| d/ | date | Appointment | | | |
| fr/ | from | Appointment | | | |
| to/ | to | Appointment | | | |
| pr/ | price | Listing | | | |
| ar/ | area | Listing | | | |
| add/ | address | Listing | | | |
| reg/ | region | Listing | | | |
| sell/ | seller | Listing | | | |
| buy/ | buyer | Listing | | | |

--------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -497,7 +497,7 @@ Commands for managing appointments between user and clients.
> ---
> **Use Case #1**: Adding appointment `8th October 2024 7pm to 9pm` for client `Bob`
>
> **Input**: `apt Bob d/08-10-24 fr/1900 to/2100`
> **Input**: `apt 1 d/08-10-24 fr/1900 to/2100`
>
> **Output**: Appointment scheduled for Bob; Phone: 94441111; Email: bob123@gmail.com; Appointment: Date: 08-10-24 (From: 19:00 To: 21:00); Tags:
>
Expand All @@ -507,7 +507,7 @@ Commands for managing appointments between user and clients.
>
> **Use Case #2**: Overriding an existing appointment for client `Bob` to be `9th October 2024 10am to 12pm` instead
>
> **Input**: `apt Bob d/09-10-24 fr/1000 to/1200`
> **Input**: `apt 1 d/09-10-24 fr/1000 to/1200`
>
> **Output**: Appointment scheduled for Bob; Phone: 94441111; Email: bob123@gmail.com; Appointment: Date: 09-10-24 (From: 10:00 To: 12:00); Tags:
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.List;

import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.Command;
Expand All @@ -12,7 +13,6 @@
import seedu.address.model.Model;
import seedu.address.model.listing.Listing;
import seedu.address.model.person.Buyer;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Seller;
import seedu.address.ui.ConfirmationDialog;
Expand All @@ -26,25 +26,26 @@ public class DeleteClientProfileCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the client profile corresponding to the client's name.\n"
+ "Parameters: CLIENT_NAME (case-insensitive)\n"
+ "Example: " + COMMAND_WORD + " Tan Wen Xuan";
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1";

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Successfully deleted %1$s ";
private final Name targetName;
private final Index targetIndex;
private final boolean skipConfirmation;

public DeleteClientProfileCommand(Name targetName) {
this(targetName, false);
public DeleteClientProfileCommand(Index targetIndex) {
this(targetIndex, false);
}

/**
* Creates a {@code DeleteClientProfileCommand} to delete the client profile with the specified name.
*
* @param targetName The name of the client profile to delete.
* @param targetIndex The index of the client profile to delete.
* @param skipConfirmation If {@code true}, the command will skip the confirmation dialog for deletion;
* if {@code false}, it will prompt the user for confirmation before deletion.
*/
public DeleteClientProfileCommand(Name targetName, boolean skipConfirmation) {
this.targetName = targetName;
public DeleteClientProfileCommand(Index targetIndex, boolean skipConfirmation) {
this.targetIndex = targetIndex;
this.skipConfirmation = skipConfirmation;
}

Expand All @@ -53,16 +54,20 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
List<Person> lastShownList = model.getFilteredPersonList();

Person personToDelete = model.getPersonByName(targetName);
if (!lastShownList.contains(personToDelete)) {
if (targetIndex.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}
Person personToDelete = lastShownList.get(targetIndex.getZeroBased());

/*if (!lastShownList.contains(personToDelete)) {
String closestMatch = findClosestMatch(targetName.toString(), lastShownList);
if (closestMatch != null) {
throw new CommandException(String.format(Messages.MESSAGE_SUGGESTION, closestMatch));
} else {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_INPUT);
}
}
}*/

if (!skipConfirmation
&& (model.hasListingsForSeller(personToDelete)
Expand Down Expand Up @@ -105,13 +110,13 @@ public boolean equals(Object other) {
}

DeleteClientProfileCommand otherDeleteCommand = (DeleteClientProfileCommand) other;
return targetName.equals(otherDeleteCommand.targetName);
return targetIndex.equals(otherDeleteCommand.targetIndex);
}

@Override
public String toString() {
return new ToStringBuilder(this)
.add("targetName", targetName)
.add("targetIndex", targetIndex)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;

import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.CollectionUtil;
import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
Expand All @@ -39,44 +41,44 @@ public class EditClientCommand extends Command {
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified "
+ "by their name. "
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: NAME (must be an existing client) "
+ "Parameters: INDEX (must be a positive integer) "
+ "[" + PREFIX_NAME + "NAME] "
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " John Doe "
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_EMAIL + "johndoe@example.com"
+ PREFIX_PHONE + "91234567 ";

public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Successfully edited %1$s!";
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book.";
public static final String MESSAGE_INVALID_PERSON = "This person does not exist in the address book.";

private final Name name;
private final Index index;
private final EditPersonDescriptor editPersonDescriptor;

/**
* @param name of the person in the filtered person list to edit
* @param index of the person in the filtered person list to edit
* @param editPersonDescriptor details to edit the person with
*/
public EditClientCommand(Name name, EditPersonDescriptor editPersonDescriptor) {
requireNonNull(name);
public EditClientCommand(Index index, EditPersonDescriptor editPersonDescriptor) {
requireNonNull(index);
requireNonNull(editPersonDescriptor);

this.name = name;
this.index = index;
this.editPersonDescriptor = new EditPersonDescriptor(editPersonDescriptor);
}

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);

if (!model.hasPersonOfName(name)) {
throw new CommandException(MESSAGE_INVALID_PERSON);
List<Person> lastShownList = model.getFilteredPersonList();

if (index.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

Person personToEdit = model.getPersonByName(name);
Person personToEdit = lastShownList.get(index.getZeroBased());
Person editedPerson = createEditedPerson(personToEdit, editPersonDescriptor);

if (!personToEdit.isSamePerson(editedPerson) && model.hasPerson(editedPerson)) {
Expand Down Expand Up @@ -124,14 +126,14 @@ public boolean equals(Object other) {
}

EditClientCommand otherEditClientCommand = (EditClientCommand) other;
return name.equals(otherEditClientCommand.name)
return index.equals(otherEditClientCommand.index)
&& editPersonDescriptor.equals(otherEditClientCommand.editPersonDescriptor);
}

@Override
public String toString() {
return new ToStringBuilder(this)
.add("name", name)
.add("name", index)
.add("editPersonDescriptor", editPersonDescriptor)
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class AddBuyersToListingCommand extends Command {
public static final String COMMAND_WORD = "addlistingbuyers";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds buyers to the listing identified by its index. "
+ "Parameters: LISTING_INDEX buyer/BUYER_INDEX [buyer/MORE_BUYER_INDEXES]...\n"
+ "Example: " + COMMAND_WORD + " 1 buyer/1 buyer/3";
+ "Parameters: LISTING_NAME buy/BUYER_NAME [buy/MORE_BUYER_NAMES]...\n"
+ "Example: " + COMMAND_WORD + " 1 buy/1 buy/3";

public static final String MESSAGE_ADD_BUYERS_SUCCESS = "Buyers added to listing: %1$s";
public static final String MESSAGE_LISTING_NOT_FOUND = "The specified listing name does not exist.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class RemoveBuyersFromListingCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Removes buyers from the listing identified by its "
+ "index. "
+ "Parameters: LISTING_INDEX buyer/BUYER_INDEX [buyer/MORE_BUYER_INDEXES]...\n"
+ "Example: " + COMMAND_WORD + " 1 buyer/1 buyer/3";
+ "Parameters: LISTING_INDEX buy/BUYER_INDEX [buy/MORE_BUYER_INDEXES]...\n"
+ "Example: " + COMMAND_WORD + " 1 buy/1 buy/3";

public static final String MESSAGE_REMOVE_BUYERS_SUCCESS = "Buyers removed from listing: %1$s.\n"
+ "Removed buyers: %2$s";
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ public class CliSyntax {

/* Prefix definitions */
public static final Prefix PREFIX_NAME = new Prefix("n/");

//=========== Client Command Prefixes =============================================================
public static final Prefix PREFIX_PHONE = new Prefix("p/");
public static final Prefix PREFIX_DATE = new Prefix("d/");
public static final Prefix PREFIX_FROM = new Prefix("fr/");
public static final Prefix PREFIX_TO = new Prefix("to/");
public static final Prefix PREFIX_EMAIL = new Prefix("e/");
public static final Prefix PREFIX_TAG = new Prefix("t/");
public static final Prefix PREFIX_PRICE = new Prefix("price/");
public static final Prefix PREFIX_AREA = new Prefix("area/");
public static final Prefix PREFIX_ADDRESS = new Prefix("address/");
public static final Prefix PREFIX_REGION = new Prefix("region/");
public static final Prefix PREFIX_SELLER = new Prefix("seller/");
public static final Prefix PREFIX_BUYER = new Prefix("buyer/");

//=========== Listing Command Prefixes =============================================================
public static final Prefix PREFIX_PRICE = new Prefix("pr/");
public static final Prefix PREFIX_AREA = new Prefix("ar/");
public static final Prefix PREFIX_ADDRESS = new Prefix("add/");
public static final Prefix PREFIX_REGION = new Prefix("reg/");
public static final Prefix PREFIX_SELLER = new Prefix("sel/");
public static final Prefix PREFIX_BUYER = new Prefix("buy/");

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.clientcommands.DeleteClientProfileCommand;
import seedu.address.logic.parser.ArgumentMultimap;
import seedu.address.logic.parser.ArgumentTokenizer;
import seedu.address.logic.parser.Parser;
import seedu.address.logic.parser.ParserUtil;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Name;

/**
* Parses input arguments and creates a new DeleteClientProfileCommand object
Expand All @@ -26,8 +26,8 @@ public DeleteClientProfileCommand parse(String args) throws ParseException {

try {
// Parse the name and return the DeleteClientProfileCommand
Name name = ParserUtil.parseName(argumentMultimap.getPreamble());
return new DeleteClientProfileCommand(name);
Index index = ParserUtil.parseIndex(argumentMultimap.getPreamble());
return new DeleteClientProfileCommand(index);
} catch (ParseException pe) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
DeleteClientProfileCommand.MESSAGE_USAGE), pe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import java.util.Optional;
import java.util.Set;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.clientcommands.EditClientCommand;
import seedu.address.logic.commands.clientcommands.EditClientCommand.EditPersonDescriptor;
import seedu.address.logic.parser.ArgumentMultimap;
import seedu.address.logic.parser.ArgumentTokenizer;
import seedu.address.logic.parser.Parser;
import seedu.address.logic.parser.ParserUtil;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Name;
import seedu.address.model.tag.Tag;

/**
Expand All @@ -37,10 +37,10 @@ public EditClientCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_TAG);

Name name;
Index index;

try {
name = ParserUtil.parseName(argMultimap.getPreamble());
index = ParserUtil.parseIndex(argMultimap.getPreamble());
} catch (ParseException pe) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditClientCommand.MESSAGE_USAGE),
pe);
Expand All @@ -66,7 +66,7 @@ public EditClientCommand parse(String args) throws ParseException {
throw new ParseException(EditClientCommand.MESSAGE_NOT_EDITED);
}

return new EditClientCommand(name, editPersonDescriptor);
return new EditClientCommand(index, editPersonDescriptor);
}

/**
Expand Down
Loading

0 comments on commit b3863c9

Please sign in to comment.