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

tpOO-03::exo-Task

parent 515f859e
Branches
No related tags found
No related merge requests found
......@@ -51,8 +51,21 @@ public class Task {
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];
this.status = TaskStatus.values()[i+1 % TaskStatus.values().length - 1];
}
}
}
public boolean isLate() {
LocalDate now = LocalDate.now();
if (this.deadline.compareTo(now) < 0) {
return true;
}
return false;
}
public void delay(int nbDays) {
this.deadline = this.deadline.plusDays(nbDays);
}
}
\ No newline at end of file
package tp03.ex01;
import java.time.LocalDate;
import java.time.chrono.ChronoLocalDate;
import java.util.Random;
import java.time.Period;
package tp03.ex01;
public class UseLocalDate {
public static boolean inArray(int[] array, int value) {
......
......@@ -2,8 +2,6 @@ package tp03.ex02;
import java.time.LocalDate;
import tp03.ex02.TaskStatus;
public class UseTask {
public static void main (String[] args) {
......@@ -19,7 +17,20 @@ public class UseTask {
System.out.println(t1);
System.out.println(t2);
// Test of isLate()
Task t3 = new Task("Finir exo3", LocalDate.of(2025, 02, 01), LocalDate.of(2025, 02, 10), 5);
Task t4 = new Task("Finir exo4", LocalDate.of(2025, 02, 01), LocalDate.of(2025, 02, 10), 5);
System.out.println(t3 + ", " + t3.isLate());
System.out.println(t4 + ", " + t4.isLate());
t3.changeStatus(TaskStatus.FINISHED);
t4.delay(30);
System.out.println(t3 + ", " + t3.isLate());
System.out.println(t4 + ", " + t4.isLate());
}
}
\ 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