Skip to content

Commit

Permalink
Make FindCommand abstract
Browse files Browse the repository at this point in the history
This is so that we can use this as a template for the sub-commands
for Find
  • Loading branch information
KrashKart committed Oct 9, 2024
1 parent adca7b5 commit c483bc1
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions src/main/java/seedu/address/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Finds and lists all persons in address book whose name contains any of the argument keywords.
* Keyword matching is case insensitive.
*/
public class FindCommand extends Command {
abstract public class FindCommand extends Command {

public static final String COMMAND_WORD = "find";

Expand All @@ -20,39 +20,39 @@ public class FindCommand extends Command {
+ "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 NameContainsKeywordsPredicate predicate;
//
// public FindCommand(NameContainsKeywordsPredicate predicate) {
// this.predicate = predicate;
// }
//
// @Override
public CommandResult execute(Model model) {
requireNonNull(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();
}
// 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();
// }
}

0 comments on commit c483bc1

Please sign in to comment.