From 2961496e7da44f1dc2654a60d3a5f7db9c598dfb Mon Sep 17 00:00:00 2001 From: serem <tomas.sereme@etu.univ-amu.fr> Date: Sun, 20 Sep 2020 21:21:50 +0200 Subject: [PATCH] Modidication des classes cohort --- tp1/Cohort.java | 12 ++++++++++++ tp1/Main.java | 10 ++++++++++ tp1/TeachingUnitResult.java | 2 ++ 3 files changed, 24 insertions(+) diff --git a/tp1/Cohort.java b/tp1/Cohort.java index e199e79..46fce8c 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 185824d..ac382f7 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 c052586..8df3c22 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; } /** -- GitLab