Skip to content

Commit

Permalink
Fix syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jxunze committed Mar 17, 2024
1 parent 58913e2 commit 8c0037e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/AboutUs.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ You can reach us at the email `seer[at]comp.nus.edu.sg`
* Role: Developer
* Responsibilities: Testing

### James Doe
### Jin Xunze

<img src="images/jxunze.png" width="200px">

Expand Down
17 changes: 11 additions & 6 deletions src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

import java.util.List;

import seedu.address.model.person.Phone;
import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;

/**
* Deletes a person identified using it's displayed index from the address book.
Expand All @@ -36,14 +35,20 @@ public DeleteCommand(Phone targetPhone) {
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
List<Person> lastShownList = model.getFilteredPersonList();

boolean exists = false;
Person personToDelete = null;
for (Person person : lastShownList) {
if (person.getPhone().equals(targetPhone)) {
model.deletePerson(person);
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(person)));
exists = true;
personToDelete = person;
break;
}
}
return new CommandResult(Messages.MESSAGE_PERSON_NOT_FOUND);
if (!exists) {
throw new CommandException(Messages.MESSAGE_PERSON_NOT_FOUND);
}
model.deletePerson(personToDelete);
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)));
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public class EditCommand extends Command {
private final EditPersonDescriptor editPersonDescriptor;

/**
* @param index of the person in the filtered person list to edit
* @param phoneNumber of the person in the filtered person list to edit
* @param editPersonDescriptor details to edit the person with
*/
public EditCommand(Phone number, EditPersonDescriptor editPersonDescriptor) {
requireNonNull(number);
public EditCommand(Phone phoneNumber, EditPersonDescriptor editPersonDescriptor) {
requireNonNull(phoneNumber);
requireNonNull(editPersonDescriptor);

this.number = number;
this.number = phoneNumber;
this.editPersonDescriptor = new EditPersonDescriptor(editPersonDescriptor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

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

import seedu.address.model.person.Phone;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Phone;

/**
* Parses input arguments and creates a new DeleteCommand object
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void execute_invalidCommandFormat_throwsParseException() {

@Test
public void execute_commandExecutionError_throwsCommandException() {
String deleteCommand = "delete 9";
String deleteCommand = "delete 12345678";
assertCommandException(deleteCommand, Messages.MESSAGE_PERSON_NOT_FOUND);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON;
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;

import org.junit.jupiter.api.Test;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.Messages;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON;

import java.util.Arrays;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON;

import org.junit.jupiter.api.Test;

Expand Down

0 comments on commit 8c0037e

Please sign in to comment.