Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Find Address #77

Merged

Conversation

Harithhh06
Copy link

@Harithhh06 Harithhh06 commented Oct 16, 2024

Things Done

  • Added find address feature
  • Added test cases for find address

close #65

@Harithhh06 Harithhh06 added this to the v1.3 milestone Oct 16, 2024
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ Complexity Δ
...edu/address/logic/commands/FindAddressCommand.java 100.00% <100.00%> (ø) 6.00 <6.00> (?)
...java/seedu/address/logic/commands/FindCommand.java 100.00% <ø> (ø) 6.00 <0.00> (ø)
...va/seedu/address/logic/parser/ClientHubParser.java 87.50% <100.00%> (+0.54%) 14.00 <0.00> (+1.00)
...address/logic/parser/FindAddressCommandParser.java 100.00% <100.00%> (ø) 3.00 <3.00> (?)
...model/person/AddressContainsKeywordsPredicate.java 100.00% <100.00%> (ø) 7.00 <7.00> (?)

@Harithhh06 Harithhh06 changed the title Branch find address Add Find Address Oct 16, 2024
Copy link

@ahmadsyuaib ahmadsyuaib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job Harith! Keep it up!

Comment on lines +103 to +110
@Test
public void parseCommand_findAddress() throws Exception {
List<String> keywords = Arrays.asList("Tampines", "Street", "1");
FindAddressCommand command = (FindAddressCommand) parser.parseCommand(
FindAddressCommand.COMMAND_WORD + " " + keywords.stream().collect(Collectors.joining(" ")));
assertEquals(new FindAddressCommand(new AddressContainsKeywordsPredicate(keywords)), command);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition of test cases!

Comment on lines +19 to +46
@Override
public boolean test(Person person) {
// Check if any of the keywords match any part of the address
return keywords.stream()
.anyMatch(keywords -> person.getAddress().value.toLowerCase().contains(keywords.toLowerCase()));
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof AddressContainsKeywordsPredicate)) {
return false;
}

AddressContainsKeywordsPredicate otherAddressContainsKeywordsPredicate =
(AddressContainsKeywordsPredicate) other;
return keywords.equals(otherAddressContainsKeywordsPredicate.keywords);
}

@Override
public String toString() {
return new ToStringBuilder(this).add("keywords", keywords).toString();
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely formatted and arranged code!

@@ -8,7 +8,7 @@
import seedu.address.model.person.NameContainsKeywordsPredicate;

/**
* Finds and lists all persons in address book whose name contains any of the argument keywords.
* Finds and lists all persons in ClientHub whose name contains any of the argument keywords.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change!

@ahmadsyuaib ahmadsyuaib merged commit 0b044df into AY2425S1-CS2103T-F10-1:master Oct 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add FIndAddress Command
2 participants