Skip to content
This repository has been archived by the owner on Mar 2, 2019. It is now read-only.

Commit

Permalink
Fix braces.
Browse files Browse the repository at this point in the history
  • Loading branch information
cricketer94 committed Oct 25, 2016
1 parent 9ae2e7d commit e7ea99e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
18 changes: 7 additions & 11 deletions src/main/java/seedu/todo/logic/commands/CompleteCommand.java
Expand Up @@ -15,15 +15,14 @@
public class CompleteCommand extends BaseCommand {
private static final String VERB_COMPLETE = "marked complete";
private static final String VERB_INCOMPLETE = "marked incomplete";


private Argument<Integer> index = new IntArgument("index");

private Argument<String> updateAllFlag = new StringArgument("all").flag("all");

@Override
protected Parameter[] getArguments() {
return new Parameter[]{ index, updateAllFlag };
return new Parameter[] { index, updateAllFlag };
}

@Override
Expand All @@ -33,28 +32,25 @@ public String getCommandName() {

@Override
protected void validateArguments() {
if(updateAllFlag.hasBoundValue() && index.hasBoundValue()) {
if (updateAllFlag.hasBoundValue() && index.hasBoundValue()) {
errors.put("You must either specify an index or an /all flag, not both!");
}
else if(!index.hasBoundValue() && !updateAllFlag.hasBoundValue()) {
} else if (!index.hasBoundValue() && !updateAllFlag.hasBoundValue()) {
errors.put(" You must specify an index or a /all flag. You have specified none! ");
}
}

@Override
public List<CommandSummary> getCommandSummary() {
return ImmutableList.of(new CommandSummary("Mark task as completed", getCommandName(),
getArgumentSummary()));
return ImmutableList.of(new CommandSummary("Mark task as completed", getCommandName(), getArgumentSummary()));
}

@Override
public CommandResult execute() throws ValidationException {
if(index.hasBoundValue()) {
if (index.hasBoundValue()) {
ImmutableTask task = this.model.update(index.getValue(), t -> t.setCompleted(!t.isCompleted()));
String feedback = task.isCompleted() ? CompleteCommand.VERB_COMPLETE : CompleteCommand.VERB_INCOMPLETE;
return taskSuccessfulResult(task.getTitle(), feedback);
}
else {
} else {
this.model.updateAll(t -> t.setCompleted(true));
String feedback = "Complete all exceuted!";
return new CommandResult(feedback);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/seedu/todo/model/TodoList.java
Expand Up @@ -67,7 +67,6 @@ private void updateEventStatus() {
todoListModified = true;
}
}

if (todoListModified) {
saveTodoList();
}
Expand Down Expand Up @@ -127,14 +126,14 @@ public ImmutableTask update(int index, Consumer<MutableTask> update) throws Vali

@Override
public void updateAll(List<Integer> indexes, Consumer<MutableTask> update) throws ValidationException {
for (Integer x: indexes){
for (Integer x: indexes) {
MutableTask task = tasks.get(x);
ValidationTask validationTask = new ValidationTask(task);
update.accept(validationTask);
validationTask.validate();
}

for (Integer i : indexes){
for (Integer i : indexes) {
MutableTask task = tasks.get(i);
update.accept(task);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/todo/model/TodoModel.java
Expand Up @@ -150,11 +150,11 @@ public ImmutableTask update(int index, Consumer<MutableTask> update) throws Vali
public void updateAll(Consumer<MutableTask> update) throws ValidationException {
saveUndoState();
Map<UUID, Integer> uuidMap = new HashMap<>();
for (int i = 0; i < tasks.size(); i++){
for (int i = 0; i < tasks.size(); i++) {
uuidMap.put(tasks.get(i).getUUID(), i);
}
List<Integer> indexes = new ArrayList<>();
for (ImmutableTask task : getObservableList()){
for (ImmutableTask task : getObservableList()) {
indexes.add(uuidMap.get(task.getUUID()));
}
todolist.updateAll(indexes, update);
Expand Down

0 comments on commit e7ea99e

Please sign in to comment.