From a44950e9662e4b5f233c25e44deedf93dfef179b Mon Sep 17 00:00:00 2001 From: KrashKart Date: Thu, 10 Oct 2024 00:02:33 +0800 Subject: [PATCH] Change message usage and other methods Temporarily correct until we implement the sub-categories of find --- .../address/logic/commands/FindCommand.java | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index 73989d93799..5eb1886d12c 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -5,7 +5,7 @@ import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; import seedu.address.model.Model; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.person.ContainsKeywordsPredicate; /** * Finds and lists all persons in address book whose name contains any of the argument keywords. @@ -15,44 +15,44 @@ abstract public class FindCommand extends Command { public static final String COMMAND_WORD = "find"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " - + "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n" + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names, contacts or emails " + + "contain any of the specified keywords (case-insensitive) and displays them as a list with indices.\n" + "Parameters: KEYWORD [MORE_KEYWORDS]...\n" + "Example: " + COMMAND_WORD + " alice bob charlie"; -// private final NameContainsKeywordsPredicate predicate; -// -// public FindCommand(NameContainsKeywordsPredicate predicate) { -// this.predicate = predicate; -// } -// -// @Override + private final ContainsKeywordsPredicate predicate; + + public FindCommand(ContainsKeywordsPredicate predicate) { + this.predicate = predicate; + } + + @Override public CommandResult execute(Model model) { -// requireNonNull(model); - model.updateFilteredPersonList(predicate); -// return new CommandResult( -// String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); -// } - -// @Override -// public boolean equals(Object other) { -// if (other == this) { -// return true; -// } -// -// // instanceof handles nulls -// if (!(other instanceof FindCommand)) { -// return false; -// } -// -// FindCommand otherFindCommand = (FindCommand) other; -// return predicate.equals(otherFindCommand.predicate); -// } -// -// @Override -// public String toString() { -// return new ToStringBuilder(this) -// .add("predicate", predicate) -// .toString(); -// } + requireNonNull(model); + model.updateFilteredPersonList(this.predicate); + return new CommandResult( + String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof FindCommand)) { + return false; + } + + FindCommand otherFindCommand = (FindCommand) other; + return this.predicate.equals(otherFindCommand.predicate); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .add("predicate", this.predicate) + .toString(); + } }