Skip to content

Commit

Permalink
Merge branch 'branch-Level-8'
Browse files Browse the repository at this point in the history
  • Loading branch information
pennhanlee committed Aug 24, 2020
2 parents 3a5c37c + 74b1efa commit 776137f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Deadline extends Task {

protected String deadline;
protected LocalDate deadline;

protected Deadline(String task, String deadline) {
protected Deadline(String task, LocalDate deadline) {
super(task);
this.deadline = deadline;
}

private String getDeadline() {
private LocalDate getDeadline() {
return this.deadline;
}

@Override
public String toString() {
String done = this.done ? "\u2713" : "\u2718";
return "[D][" + done + "] " + this.task + "(by:" + this.deadline + ")";
String date = this.deadline.format(DateTimeFormatter.ofPattern("MMM d yyyy"));
return "[D][" + done + "] " + this.task + "(by: " + date + ")";
}
}
4 changes: 3 additions & 1 deletion src/main/java/Processor.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import java.util.ArrayList;
import java.time.LocalDate;

public class Processor {

Expand Down Expand Up @@ -51,7 +52,8 @@ public String processorAdd(String cmd, ArrayList<Task> arraylst) throws DukeExce
throw new DukeException("_________________________________________\n" + message + "\n_________________________________________");
} else {
String[] secondarr = stringarr[1].split("/by", 2);
Deadline deadline = new Deadline(secondarr[0], secondarr[1]);
LocalDate date = LocalDate.parse(secondarr[1].trim());
Deadline deadline = new Deadline(secondarr[0], date);
arraylst.add(deadline);
}
} else if (stringarr[0].equals("event")) {
Expand Down

0 comments on commit 776137f

Please sign in to comment.