diff --git a/tp1/Cohort.java b/tp1/Cohort.java index e199e790e8c0dad4a95033147e150e6a0a1a8fd6..46fce8cb61c431917644e63901fd40ba4d40682b 100644 --- a/tp1/Cohort.java +++ b/tp1/Cohort.java @@ -24,6 +24,8 @@ public class Cohort { * @param student the student to be added to the cohort */ public void addStudent(Student student){ + students.add(student); + } /** @@ -31,6 +33,7 @@ public class Cohort { * @return the list of students of the cohort. */ public List<Student> getStudents(){ + return List.copyOf (students); } /** @@ -38,9 +41,17 @@ public class Cohort { * grade. */ public void printStudentsResults(){ + printName(); + System.out.println(); + for (Student student : students){ + student.printResults(); + System.out.println(); + + } } private void printName(){ + System.out.println(this.toString()); } /** @@ -49,5 +60,6 @@ public class Cohort { */ @Override public String toString() { + return name; } } diff --git a/tp1/Main.java b/tp1/Main.java index 185824dd55c4a42adf72eae2a8f98e761dda9b8e..ac382f769235be8779fd069702e3791ec9384fa9 100644 --- a/tp1/Main.java +++ b/tp1/Main.java @@ -1,4 +1,14 @@ public class Main { public static void main(String[] args){ + Student student1 = new Student("Tomas","Sereme"); + Student student2 = new Student("Zidani fahed","Imed"); + student1.addResult("programmation2", new Grade(20)); + student2.addResult("programmation2", new Grade(0)); + student1.addResult("Structures discretes",new Grade(20)); + student2.addResult("Structures discretes", new Grade(0)); + Cohort cohort = new Cohort("L2 informatique"); + cohort.addStudent(student1); + cohort.addStudent(student2); + cohort.printStudentsResults(); } } diff --git a/tp1/TeachingUnitResult.java b/tp1/TeachingUnitResult.java index c052586a62e9513c55979121bb6ff8b67972fc71..8df3c22322d38f7b58adfc9f18eaa7ca0c9db346 100644 --- a/tp1/TeachingUnitResult.java +++ b/tp1/TeachingUnitResult.java @@ -26,6 +26,8 @@ public class TeachingUnitResult { * @return the grade associated to the result */ public Grade getGrade() { + grade = teachingUnitName + grade; + return grade; } /**