Skip to content

Commit

Permalink
Fix time matching bug
Browse files Browse the repository at this point in the history
  • Loading branch information
varung97 committed Oct 27, 2016
1 parent 4579f6b commit defeece
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/main/java/seedu/manager/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ private HashMap<TaskProperties, Optional<TaskProperty>> buildProperties(HashMap<
properties.put(prop.getKey(), taskProperty);
}

System.out.println(properties);

return properties;
}

Expand Down
10 changes: 0 additions & 10 deletions src/main/java/seedu/manager/model/task/EndTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,4 @@ public class EndTime extends Time {
public EndTime(String endTime) throws IllegalValueException {
super(endTime);
}

/**
* Checks if the end time of a task is equal to or earlier than that of the search function's input
*/
@Override
public boolean matches(TaskProperty endTime) {
assert endTime instanceof EndTime;

return (!((EndTime) endTime).value.before(this.value));
}
}
10 changes: 0 additions & 10 deletions src/main/java/seedu/manager/model/task/StartTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,4 @@ public class StartTime extends Time {
public StartTime(String startTime) throws IllegalValueException {
super(startTime);
}

/**
* Checks if the start time of a task is equal to or later than that of the search function's input
*/
@Override
public boolean matches(TaskProperty startTime) {
assert startTime instanceof StartTime;

return (!((StartTime) startTime).value.after(this.value));
}
}
14 changes: 13 additions & 1 deletion src/main/java/seedu/manager/model/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,19 @@ public boolean matches(HashMap<TaskProperties, Optional<TaskProperty>> other) {
for (TaskProperties property : TaskProperties.values()) {
if (other.get(property).isPresent()) {
if (!this.properties.get(property).isPresent()) {
return false;
if (property.equals(TaskProperties.STARTTIME)) {
if (!(this.properties.get(TaskProperties.ENDTIME).isPresent() &&
this.properties.get(TaskProperties.ENDTIME).get().matches(other.get(property).get()))) {
return false;
}
} else if (property.equals(TaskProperties.ENDTIME)) {
if (!(this.properties.get(TaskProperties.STARTTIME).isPresent() &&
this.properties.get(TaskProperties.STARTTIME).get().matches(other.get(property).get()))) {
return false;
}
} else {
return false;
}
} else if (!this.properties.get(property).get().matches(other.get(property).get())){
return false;
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/seedu/manager/model/task/Time.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,17 @@ public Date getTime() {
return value;
}

/**
* Checks if the start time of a task is equal to or later than that of the search function's input
*/
@Override
public boolean matches(TaskProperty time) {
if (time instanceof StartTime) {
return (!((StartTime) time).value.after(this.value));
} else if (time instanceof EndTime) {
return (!((EndTime) time).value.before(this.value));
} else {
return false;
}
}
}

0 comments on commit defeece

Please sign in to comment.