diff --git a/tp1/Student.java b/tp1/Student.java index 2424e329aa800718cd6ee27905d111c4d2fd9d17..c47b3cf88c34c08afe0cc8590bed7be421c837ab 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 0000000000000000000000000000000000000000..b8b18f0341ce43c9cca49099501406d326ad4116 --- /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 afd4fbe351a8bcf5bc1584ddece8bfb52756f791..66c23eba520001f71d8b7a10785b83cb86131403 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(){ - - } }