From 854f607204121cc8c6d788d44f1d571c1dc8237a Mon Sep 17 00:00:00 2001
From: Samuel Turpin <samuel.turpin.etu@univ-lille.fr>
Date: Thu, 23 May 2024 10:30:27 +0200
Subject: [PATCH] tp4 finish

---
 src/tp04/StudentAbs.java | 29 ++++++++++++++++++++++++++++-
 src/tp04/YearGroup.java  |  9 +++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 src/tp04/YearGroup.java

diff --git a/src/tp04/StudentAbs.java b/src/tp04/StudentAbs.java
index 36973b1..298c358 100644
--- a/src/tp04/StudentAbs.java
+++ b/src/tp04/StudentAbs.java
@@ -2,9 +2,36 @@ package tp04;
 
 public class StudentAbs extends Student
 {
-    public StudentAbs(Person pers, double[] grades)
+    private int nbAbsence;
+
+    public StudentAbs(Student pers, double[] grades, int abs)
     {
         super(pers, grades);
+        this.nbAbsence=abs;
+    }
+
+    public int getNbAbsence() {
+        return nbAbsence;
+    }
+
+    public boolean warning(int thresholdAbs, double thresholdAvg)
+    {
+        return getAverage() <= thresholdAvg || getNbAbsence() >= thresholdAbs;
+    }
+
+    public boolean validation(int thresholdAbs, double thresholdAvg)
+    {
+        return getAverage() >= thresholdAvg || getNbAbsence() <= thresholdAbs;
     }
 
+    public boolean equals(StudentAbs abs)
+    {
+        return abs.getNbAbsence() == this.getNbAbsence();
+    }
+
+    @Override
+    public String toString()
+    {
+        return getPers().getForename()+" "+getPers().getName()+", nbAbs="+getNbAbsence();
+    }
 }
\ No newline at end of file
diff --git a/src/tp04/YearGroup.java b/src/tp04/YearGroup.java
new file mode 100644
index 0000000..56c93cc
--- /dev/null
+++ b/src/tp04/YearGroup.java
@@ -0,0 +1,9 @@
+package tp04;
+
+public class YearGroup extends StudentAbs
+{
+    public YearGroup(Student pers, double[] grades, int abs)
+    {
+        super(pers, grades, abs);
+    }
+}
\ No newline at end of file
-- 
GitLab