Skip to content
Snippets Groups Projects
Commit d4aa5796 authored by Ethan Robert's avatar Ethan Robert
Browse files

Added Task class

parent a2eda49d
Branches
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment