From 0bcbf939d556bd390f98076f57997a53dfe53843 Mon Sep 17 00:00:00 2001 From: Leo Rangheard <leo.rangheard@etu.univ-amu.fr> Date: Thu, 17 Sep 2020 01:34:07 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20Student=20et=20TestStudent,=20fin?= =?UTF-8?q?=20de=20TestCohort=20testAddResults()=20d=C3=A9lib=C3=A9r=C3=A9?= =?UTF-8?q?ment=20fausse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tp1/Student.java | 2 +- tp1/TestCohort.java | 35 +++++++++++++++++++++++++++++++++++ tp1/TestStudent.java | 8 -------- 3 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 tp1/TestCohort.java diff --git a/tp1/Student.java b/tp1/Student.java index 2424e32..c47b3cf 100644 --- a/tp1/Student.java +++ b/tp1/Student.java @@ -41,7 +41,7 @@ public class Student { */ @Override public String toString() { - return firstName + lastName; + return firstName + " " + lastName; } diff --git a/tp1/TestCohort.java b/tp1/TestCohort.java new file mode 100644 index 0000000..b8b18f0 --- /dev/null +++ b/tp1/TestCohort.java @@ -0,0 +1,35 @@ +import java.util.ArrayList; +import java.util.List; + +public class TestCohort { + public static void main(String[] args){ + TestCohort test = new TestCohort(); + if (test.testGetStudents() == true) + System.out.println("testGetStudents = correct"); + else + System.out.println("testGetStudents = incorrect"); + if (test.testToString() == true) + System.out.println("testToString = correct"); + else + System.out.println("testToString = incorrect"); + } + public boolean testGetStudents(){ + List<Student> testStudents = new ArrayList<>(); + Cohort testCohort = new Cohort("Programmation"); + testStudents.add(new Student("Leo", "Rangheard")); + testStudents.add(new Student("Ahmed", "Souissi")); + testCohort.addStudent(new Student("Leo", "Rangheard")); + testCohort.addStudent(new Student("Ahmed", "Souissi")); + if (testCohort.getStudents().equals(testStudents)) + return true; + else + return false; + } + public boolean testToString(){ + Cohort testCohort = new Cohort("Programmation"); + if (testCohort.toString().equals("Programmation")) + return true; + else + return false; + } +} diff --git a/tp1/TestStudent.java b/tp1/TestStudent.java index afd4fbe..66c23eb 100644 --- a/tp1/TestStudent.java +++ b/tp1/TestStudent.java @@ -24,11 +24,6 @@ public class TestStudent { System.out.println("averageGrade = correct"); else System.out.println("averageGrade = incorrect"); - - if (test.testPrintResults() == true) - System.out.println("printResults = correct"); - else - System.out.println("printResults = incorrect"); } public boolean testAddResult(){ Grade grade = new Grade(11.7); @@ -72,7 +67,4 @@ public class TestStudent { else return false; } - public boolean testPrintResults(){ - - } } -- GitLab