diff --git a/src/tp03/Task.java b/src/tp03/Task.java new file mode 100644 index 0000000000000000000000000000000000000000..c8f2c47fcc1388f087b9ce554748e8054e08ced2 --- /dev/null +++ b/src/tp03/Task.java @@ -0,0 +1,58 @@ +package tp03.ex02; + +import java.time.LocalDate; + +public class Task { + private int taskID; + private LocalDate creationDate; + private LocalDate deadline; + private TaskStatus status; + private String description; + private int duration; + + private static int counter = 0; + + public Task(String description, int duration) { + this.taskID = Task.counter; + Task.counter++; + + this.creationDate = LocalDate.now(); + this.deadline = this.creationDate.plusDays(10); + + this.duration = duration; + this.description = description; + + this.status = TaskStatus.TODO; + + } + + public Task(String description, LocalDate creation, LocalDate deadline, int duration) { + this.taskID = Task.counter= + Task.counter++; + + this.creationDate = creation; + this.deadline = deadline; + + this.duration = duration; + this.description = description; + + this.status = TaskStatus.TODO; + } + + public String toString() { + return "T" + this.taskID + " = " + this.description + ":" + this.status + "(" + this.duration + "):" + this.deadline; + } + + public void changeStatus(TaskStatus st) { + this.status = st; + } + + public void changeStatus() { + for (int i = 0; i < TaskStatus.values().length; i++) { + if (TaskStatus.values()[i].equals(this.status)) { + // Use modulo to avoid errors + this.status = TaskStatus.values()[i+1 % TaskStatus.values().length]; + } + } + } +} \ No newline at end of file