forked from nus-cs2103-AY2021S1/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
213 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,57 @@ | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
/** | ||
* Class to represent a deadline object. | ||
* @author vanGoghhh | ||
*/ | ||
|
||
public class Deadline extends Task { | ||
public class Deadline extends TimedTask { | ||
|
||
private LocalDate by; | ||
/** | ||
* Constructor for a timed task. | ||
* | ||
* @param description details of the task. | ||
* @param dueDate deadline of the task. | ||
*/ | ||
public Deadline(String description, LocalDate dueDate) { | ||
super(description, dueDate); | ||
} | ||
|
||
/** | ||
* Constructor for deadline class. | ||
* @param description description of the deadline. | ||
* @param by date that the deadline is dued. | ||
* Method to convert deadline to a file friendly format. | ||
* @return string representation of file format. | ||
*/ | ||
public Deadline(String description, LocalDate by) { | ||
super(description); | ||
this.by = by; | ||
@Override | ||
protected String inputInFile() { | ||
return "D//" + this.getTaskStatus() + "//" | ||
+ super.getDescription() + "//" + this.getTaskDeadline(); | ||
} | ||
|
||
/** | ||
* Updates the task with new date. | ||
* @param newDueDate new date to update with. | ||
* @return task with new date. | ||
*/ | ||
@Override | ||
protected LocalDate getTaskDeadline() { | ||
return by; | ||
protected Deadline updateTimedTaskDeadline(LocalDate newDueDate) { | ||
Deadline newDeadline = new Deadline(super.getDescription(), newDueDate); | ||
if (this.getStatus()) { | ||
newDeadline.markAsDone(); | ||
} | ||
return newDeadline; | ||
} | ||
|
||
/** | ||
* Prints the deadline object. | ||
* @return string representation of a deadline. | ||
* Updates the task with new description | ||
* @param newDescription new task description. | ||
* @return task with new description. | ||
*/ | ||
@Override | ||
public String toString() { | ||
return "[D]" + super.toString() + " (by: " | ||
+ by.format(DateTimeFormatter.ofPattern("d MMM uuuu")) | ||
+ ")"; | ||
protected Deadline updateTaskDescription(String newDescription) { | ||
Deadline newDeadline = new Deadline(newDescription, super.getTaskDeadline()); | ||
if (this.getStatus()) { | ||
newDeadline.markAsDone(); | ||
} | ||
return newDeadline; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,56 @@ | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
/** | ||
* Class to represent an event object. | ||
* @author vanGoghhh | ||
*/ | ||
|
||
public class Event extends Task { | ||
|
||
private LocalDate at; | ||
public class Event extends TimedTask { | ||
|
||
/** | ||
* Constructor for event class. | ||
* @param description description of the event. | ||
* @param at duedate of the event. | ||
* @param dueDate duedate of the event. | ||
*/ | ||
public Event(String description, LocalDate dueDate) { | ||
super(description, dueDate); | ||
} | ||
|
||
/** | ||
* Method to convert deadline to a file friendly format. | ||
* @return string representation of file format. | ||
*/ | ||
public Event(String description, LocalDate at) { | ||
super(description); | ||
this.at = at; | ||
@Override | ||
protected String inputInFile() { | ||
return "E//" + this.getTaskStatus() + "//" | ||
+ super.getDescription() + "//" + this.getTaskDeadline(); | ||
} | ||
|
||
/** | ||
* Returns deadline for the event. | ||
* @return deadline of event. | ||
* Updates the task with new date. | ||
* @param newDueDate new date to update with. | ||
* @return task with new date. | ||
*/ | ||
@Override | ||
protected LocalDate getTaskDeadline() { | ||
return at; | ||
protected Event updateTimedTaskDeadline(LocalDate newDueDate) { | ||
Event newEvent = new Event(super.getDescription(), newDueDate); | ||
if (this.getStatus()) { | ||
newEvent.markAsDone(); | ||
} | ||
return newEvent; | ||
} | ||
|
||
/** | ||
* Prints the event object. | ||
* @return string representation of the event object. | ||
* Updates the task with new description | ||
* @param newDescription new task description. | ||
* @return task with new description. | ||
*/ | ||
@Override | ||
public String toString() { | ||
return "[E]" + super.toString() + " (at: " | ||
+ at.format(DateTimeFormatter.ofPattern("d MMM uuuu")) + ")"; | ||
protected Event updateTaskDescription(String newDescription) { | ||
Event newEvent = new Event(newDescription, super.getTaskDeadline()); | ||
if (this.getStatus()) { | ||
newEvent.markAsDone(); | ||
} | ||
return newEvent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.