From 52bdadefe0db0305b82f21f0f100eed9df8bd6d6 Mon Sep 17 00:00:00 2001
From: Ethan Robert <ethan.rbrt90@gmail.com>
Date: Fri, 28 Feb 2025 10:04:44 +0100
Subject: [PATCH] tpOO-03::exo-Task

---
 src/tp03/Task.java         | 15 ++++++++++++++-
 src/tp03/UseLocalDate.java |  4 ++--
 src/tp03/UseTask.java      | 17 ++++++++++++++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/tp03/Task.java b/src/tp03/Task.java
index c8f2c47..47e196c 100644
--- a/src/tp03/Task.java
+++ b/src/tp03/Task.java
@@ -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
diff --git a/src/tp03/UseLocalDate.java b/src/tp03/UseLocalDate.java
index e8760f2..e3ff6f4 100644
--- a/src/tp03/UseLocalDate.java
+++ b/src/tp03/UseLocalDate.java
@@ -1,10 +1,10 @@
+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) {
diff --git a/src/tp03/UseTask.java b/src/tp03/UseTask.java
index 98d8ef3..d56784d 100644
--- a/src/tp03/UseTask.java
+++ b/src/tp03/UseTask.java
@@ -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
-- 
GitLab