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

[W6.2b][F09-4] Rachel Lee #135

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un
|===========================================================================================================================================
|Priority |As a ... |I want to ... |So that I can...
|`* * *` |new user |see usage instructions |refer to instructions when I forget how to use the App
|`* * *` |user |add a new person |
|`* * *` |user |add a new person | add details of people
|`* * *` |user |delete a person |remove entries that I no longer need
|`* * *` |user |find a person by name |locate details of persons without having to go through the entire list
|`* * *` |user |edit details of a person |update details or make small changes without having to remove and re-add the person
|`* *` |user |hide <<private-contact-detail, private contact details>> by default |minimize chance of someone else seeing them by accident
|`*` |user with many persons in the address book |sort persons by name |locate a person easily
|===========================================================================================================================================
Expand Down
2 changes: 2 additions & 0 deletions src/seedu/addressbook/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,6 @@ public int getTargetIndex() {
public void setTargetIndex(int targetIndex) {
this.targetIndex = targetIndex;
}

public boolean isMutating() { return true; }
Copy link

Choose a reason for hiding this comment

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

This method should have a header comment. If not, users of the method as well as those who overrides method will not know how exactly the method behaves.

}
2 changes: 2 additions & 0 deletions src/seedu/addressbook/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ private List<ReadOnlyPerson> getPersonsWithNameContainingAnyKeyword(Set<String>
return matchedPersons;
}

@Override
public boolean isMutating() { return false; }
}
4 changes: 4 additions & 0 deletions src/seedu/addressbook/commands/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ public class HelpCommand extends Command {
public CommandResult execute() {
return new CommandResult(MESSAGE_ALL_USAGES);
}

@Override
public boolean isMutating() { return false; }

}
3 changes: 3 additions & 0 deletions src/seedu/addressbook/commands/IncorrectCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ public CommandResult execute() {
return new CommandResult(feedbackToUser);
}

@Override
public boolean isMutating() { return false; }

}
3 changes: 3 additions & 0 deletions src/seedu/addressbook/commands/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ public CommandResult execute() {
List<ReadOnlyPerson> allPersons = addressBook.getAllPersons().immutableListView();
return new CommandResult(getMessageForPersonListShownSummary(allPersons), allPersons);
}

@Override
public boolean isMutating() { return false; }
}
3 changes: 3 additions & 0 deletions src/seedu/addressbook/commands/ViewAllCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ public CommandResult execute() {
return new CommandResult(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}
}

@Override
public boolean isMutating() { return false; }
}
3 changes: 3 additions & 0 deletions src/seedu/addressbook/commands/ViewCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ public CommandResult execute() {
}
}

@Override
public boolean isMutating() { return false; }

}
6 changes: 4 additions & 2 deletions src/seedu/addressbook/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public CommandResult execute(String userCommandText) throws Exception {
}

/**
* Executes the command, updates storage, and returns the result.
* Executes the command, updates storage if data is mutated, and returns the result.
*
* @param command user command
* @return result of the command
Expand All @@ -85,7 +85,9 @@ public CommandResult execute(String userCommandText) throws Exception {
private CommandResult execute(Command command) throws Exception {
command.setData(addressBook, lastShownList);
CommandResult result = command.execute();
storage.save(addressBook);
if (command.isMutating() == true) {
storage.save(addressBook);
}
return result;
}

Expand Down