Skip to content

Commit

Permalink
Merge pull request #46 from CS2103AUG2016-W10-C2/add-description-to-d…
Browse files Browse the repository at this point in the history
…eadline-and-test

Add description functionality to deadline
  • Loading branch information
tjonganthony authored Oct 18, 2016
2 parents 9ef5bd0 + 7260146 commit 97adbdc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public AddCommand(String title, Set<String> tags)
* @throws IllegalValueException if any of the raw values are invalid
*/
// TODO: Implement Add for other types of entry
public AddCommand(String title, LocalDateTime deadline, Set<String> tags)
public AddCommand(String title, LocalDateTime deadline, Set<String> tags, String description)
throws IllegalValueException {
final Set<Tag> tagSet = new HashSet<>();
for (String tagName : tags) {
Expand All @@ -59,7 +59,8 @@ public AddCommand(String title, LocalDateTime deadline, Set<String> tags)
this.toAdd = new Deadline(
new Title(title),
deadline,
new UniqueTagList(tagSet)
new UniqueTagList(tagSet),
description
);
}

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/seedu/address/logic/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public class Parser {

private static final Pattern DEADLINE_DATA_ARGS_FORMAT = // '/' forward slashes are reserved for delimiter prefixes
Pattern.compile("(?<title>[^/]+)"
+ "(?<deadlineArguments>(?: deadline/\\d{4}-\\d{1,2}-\\d{1,2} \\d{2}:\\d{2}))" // Date time format: DD/MM/YYYY/HH:MM
+ "(?<tagArguments>(?: t/[^/]+)?)"); // comma separated tags;
+ "(?<deadlineArguments>(?: dl/\\d{4}-\\d{1,2}-\\d{1,2} \\d{2}:\\d{2}))" // Date time format: DD/MM/YYYY/HH:MM
+ "(?<tagArguments>(?: t/[^/]+)?)" // comma separated tags;
+ "(?<desc>(?: desc/[^/]*)?)");

private static final Pattern EDIT_TASK_ARGS_FORMAT = Pattern
.compile("(?<targetIndex>\\d+)\\s*(?<title>[\\s\\w\\d]*)"
Expand Down Expand Up @@ -131,7 +132,7 @@ private Command prepareAdd(String args) {
}
if (deadlineMatcher.matches()) {
try {
return new AddCommand(deadlineMatcher.group("title"), getDeadlineFromArgument(deadlineMatcher.group("deadlineArguments")), getTagsFromArgs(deadlineMatcher.group("tagArguments")));
return new AddCommand(deadlineMatcher.group("title"), getDeadlineFromArgument(deadlineMatcher.group("deadlineArguments")), getTagsFromArgs(deadlineMatcher.group("tagArguments")), getDescriptionFromArgs(deadlineMatcher.group("desc")));
} catch (IllegalValueException ive) {
return new IncorrectCommand(ive.getMessage());
}
Expand Down Expand Up @@ -207,7 +208,7 @@ private static LocalDateTime getDeadlineFromArgument(String deadlineArguments) t
return LocalDateTime.now();
}
// remove the tag.
final List<String> cleanedStrings = Arrays.asList(deadlineArguments.replaceFirst(" deadline/", "").split(" "));
final List<String> cleanedStrings = Arrays.asList(deadlineArguments.replaceFirst(" dl/", "").split(" "));
return LocalDateTime.parse(cleanedStrings.get(0) + "T" + cleanedStrings.get(1) + ":00");
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/seedu/address/model/task/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
public final class Deadline extends FloatingTask{
protected ObjectProperty<LocalDateTime> deadline;

public Deadline(Title title, LocalDateTime deadline, UniqueTagList tags) {
this(title, deadline, tags, false);
public Deadline(Title title, LocalDateTime deadline, UniqueTagList tags, String desc) {
this(title, deadline, tags, false, desc);
}

public Deadline(Title title, LocalDateTime deadline, UniqueTagList tags, boolean isMarked) {
super(title, tags, isMarked);
public Deadline(Title title, LocalDateTime deadline, UniqueTagList tags, boolean isMarked, String desc) {
super(title, tags, isMarked, desc);
assert !CollectionUtil.isAnyNull(deadline);
this.deadline = new SimpleObjectProperty<>(deadline);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/storage/XmlAdaptedEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Entry toModelType() throws IllegalValueException {
if (deadline == null) {
return new FloatingTask(title, tags, isMarked, description);
} else {
return new Deadline(title, LocalDateTime.parse(deadline), tags, isMarked);
return new Deadline(title, LocalDateTime.parse(deadline), tags, isMarked, description);
}
}
}

0 comments on commit 97adbdc

Please sign in to comment.