diff --git a/tp1/.classpath b/tp1/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..3f3893aff96296c1ce15c61728d13a5d97589bbe --- /dev/null +++ b/tp1/.classpath @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="src" path=""/> + <classpathentry kind="output" path=""/> +</classpath> diff --git a/tp1/.idea/dictionaries/teobk.xml b/tp1/.idea/dictionaries/teobk.xml new file mode 100644 index 0000000000000000000000000000000000000000..694b2057a0490dbdcd89e50cf4328183ffeac9d4 --- /dev/null +++ b/tp1/.idea/dictionaries/teobk.xml @@ -0,0 +1,3 @@ +<component name="ProjectDictionaryState"> + <dictionary name="teobk" /> +</component> \ No newline at end of file diff --git a/tp1/.idea/encodings.xml b/tp1/.idea/encodings.xml new file mode 100644 index 0000000000000000000000000000000000000000..15a15b218a29e09c9190992732698d646e4d659a --- /dev/null +++ b/tp1/.idea/encodings.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Encoding" addBOMForNewFiles="with NO BOM" /> +</project> \ No newline at end of file diff --git a/tp1/.idea/misc.xml b/tp1/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..bded3c4b66fa0cd872642e7917c65b429bca5b0d --- /dev/null +++ b/tp1/.idea/misc.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectInspectionProfilesVisibleTreeState"> + <entry key="Project Default"> + <profile-state> + <expanded-state> + <State /> + <State> + <id>Android</id> + </State> + <State> + <id>CorrectnessLintAndroid</id> + </State> + <State> + <id>GPathGroovy</id> + </State> + <State> + <id>Groovy</id> + </State> + <State> + <id>JSON and JSON5</id> + </State> + <State> + <id>Java</id> + </State> + <State> + <id>LintAndroid</id> + </State> + <State> + <id>PerformanceLintAndroid</id> + </State> + <State> + <id>Plugin DevKit</id> + </State> + <State> + <id>Probable bugsJava</id> + </State> + <State> + <id>SecurityLintAndroid</id> + </State> + <State> + <id>XML</id> + </State> + <State> + <id>XPath</id> + </State> + </expanded-state> + <selected-state> + <State> + <id>Android</id> + </State> + </selected-state> + </profile-state> + </entry> + </component> + <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK" /> +</project> \ No newline at end of file diff --git a/tp1/.idea/modules.xml b/tp1/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..30868bc209a69f34ce346bfab85f0320ed0fbc0b --- /dev/null +++ b/tp1/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/tp1.iml" filepath="$PROJECT_DIR$/.idea/tp1.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/tp1/.idea/tp1.iml b/tp1/.idea/tp1.iml new file mode 100644 index 0000000000000000000000000000000000000000..d6ebd4805981b8400db3e3291c74a743fef9a824 --- /dev/null +++ b/tp1/.idea/tp1.iml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$" /> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file diff --git a/tp1/.idea/workspace.xml b/tp1/.idea/workspace.xml new file mode 100644 index 0000000000000000000000000000000000000000..8167f3cda996c46ac14cd11c78715c3ca237a30d --- /dev/null +++ b/tp1/.idea/workspace.xml @@ -0,0 +1,270 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ChangeListManager"> + <list default="true" id="356dda69-a3a0-4b04-bc78-3f3066602f2d" name="Default Changelist" comment="" /> + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> + <option name="SHOW_DIALOG" value="false" /> + <option name="HIGHLIGHT_CONFLICTS" value="true" /> + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> + <option name="LAST_RESOLUTION" value="IGNORE" /> + </component> + <component name="CoverageDataManager"> + <SUITE FILE_PATH="coverage/tp1$null.ic" NAME="null Coverage Results" MODIFIED="1600077124422" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" /> + </component> + <component name="FileEditorManager"> + <leaf> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/Cohort.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="15"> + <caret line="1" selection-start-line="1" selection-end-line="1" /> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/Grade.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="439"> + <caret line="49" column="12" lean-forward="true" selection-start-line="49" selection-start-column="12" selection-end-line="49" selection-end-column="12" /> + <folding> + <element signature="e#576#577#0" expanded="true" /> + <element signature="e#604#605#0" expanded="true" /> + <element signature="e#785#786#0" expanded="true" /> + <element signature="e#808#809#0" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/TestGrade.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="240"> + <caret line="16" column="57" lean-forward="true" selection-start-line="16" selection-start-column="57" selection-end-line="16" selection-end-column="57" /> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/Main.java"> + <provider selected="true" editor-type-id="text-editor" /> + </entry> + </file> + </leaf> + </component> + <component name="IdeDocumentHistory"> + <option name="CHANGED_PATHS"> + <list> + <option value="$PROJECT_DIR$/Grade.java" /> + </list> + </option> + </component> + <component name="ProjectFrameBounds" fullScreen="true"> + <option name="width" value="1440" /> + <option name="height" value="900" /> + </component> + <component name="ProjectView"> + <navigator proportions="" version="1"> + <foldersAlwaysOnTop value="true" /> + </navigator> + <panes> + <pane id="PackagesPane" /> + <pane id="Scope" /> + <pane id="ProjectPane"> + <subPane> + <expand> + <path> + <item name="tp1" type="b2602c69:ProjectViewProjectNode" /> + <item name="tp1" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="tp1" type="b2602c69:ProjectViewProjectNode" /> + <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" /> + </path> + </expand> + <select /> + </subPane> + </pane> + </panes> + </component> + <component name="PropertiesComponent"> + <property name="last_opened_file_path" value="$PROJECT_DIR$" /> + <property name="project.structure.last.edited" value="Project" /> + <property name="project.structure.proportion" value="0.0" /> + <property name="project.structure.side.proportion" value="0.2" /> + <property name="settings.editor.selected.configurable" value="reference.settings.ide.settings.spelling" /> + </component> + <component name="RunDashboard"> + <option name="ruleStates"> + <list> + <RuleState> + <option name="name" value="ConfigurationTypeDashboardGroupingRule" /> + </RuleState> + <RuleState> + <option name="name" value="StatusDashboardGroupingRule" /> + </RuleState> + </list> + </option> + </component> + <component name="RunManager"> + <configuration name="null" type="JUnit" factoryName="JUnit" nameIsGenerated="true"> + <module name="tp1" /> + <option name="ALTERNATIVE_JRE_PATH" value="11" /> + <option name="MAIN_CLASS_NAME" value="" /> + <option name="METHOD_NAME" value="" /> + <option name="TEST_OBJECT" value="class" /> + <option name="PARAMETERS" value="" /> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + </component> + <component name="SvnConfiguration"> + <configuration>$USER_HOME$/.subversion</configuration> + </component> + <component name="TaskManager"> + <task active="true" id="Default" summary="Default task"> + <changelist id="356dda69-a3a0-4b04-bc78-3f3066602f2d" name="Default Changelist" comment="" /> + <created>1600071827614</created> + <option name="number" value="Default" /> + <option name="presentableId" value="Default" /> + <updated>1600071827614</updated> + </task> + <servers /> + </component> + <component name="TestHistory"> + <history-entry file="null - 2020.09.14 at 11h 40m 58s.xml"> + <configuration name="null" configurationId="JUnit" /> + </history-entry> + <history-entry file="null - 2020.09.14 at 11h 52m 07s.xml"> + <configuration name="null" configurationId="JUnit" /> + </history-entry> + </component> + <component name="ToolWindowManager"> + <frame x="0" y="0" width="1440" height="900" extended-state="0" /> + <editor active="true" /> + <layout> + <window_info id="Image Layers" /> + <window_info id="Designer" /> + <window_info id="UI Designer" /> + <window_info id="Capture Tool" /> + <window_info id="Favorites" side_tool="true" /> + <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25" /> + <window_info id="Structure" order="1" side_tool="true" weight="0.25" /> + <window_info anchor="bottom" id="Version Control" /> + <window_info anchor="bottom" id="Terminal" /> + <window_info anchor="bottom" id="Event Log" side_tool="true" /> + <window_info anchor="bottom" id="Messages" /> + <window_info anchor="bottom" id="Message" order="0" /> + <window_info anchor="bottom" id="Find" order="1" /> + <window_info anchor="bottom" id="Run" order="2" weight="0.32902467" /> + <window_info anchor="bottom" id="Debug" order="3" weight="0.4" /> + <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> + <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> + <window_info anchor="bottom" id="TODO" order="6" /> + <window_info anchor="right" id="Palette" /> + <window_info anchor="right" id="Theme Preview" /> + <window_info anchor="right" id="Capture Analysis" /> + <window_info anchor="right" id="Palette	" /> + <window_info anchor="right" id="Maven" /> + <window_info active="true" anchor="right" id="Coverage" side_tool="true" visible="true" weight="0.3298611" /> + <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> + <window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> + <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> + </layout> + </component> + <component name="editorHistoryManager"> + <entry file="file://$PROJECT_DIR$/Cohort.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="15"> + <caret line="1" selection-start-line="1" selection-end-line="1" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/Main.java"> + <provider selected="true" editor-type-id="text-editor" /> + </entry> + <entry file="file://$PROJECT_DIR$/Grade.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="439"> + <caret line="49" column="12" lean-forward="true" selection-start-line="49" selection-start-column="12" selection-end-line="49" selection-end-column="12" /> + <folding> + <element signature="e#576#577#0" expanded="true" /> + <element signature="e#604#605#0" expanded="true" /> + <element signature="e#785#786#0" expanded="true" /> + <element signature="e#808#809#0" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/TestGrade.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="240"> + <caret line="16" column="57" lean-forward="true" selection-start-line="16" selection-start-column="57" selection-end-line="16" selection-end-column="57" /> + </state> + </provider> + </entry> + </component> + <component name="masterDetails"> + <states> + <state key="GlobalLibrariesConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="JdkListConfigurable.UI"> + <settings> + <last-edited>11</last-edited> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="ProjectJDKs.UI"> + <settings> + <last-edited>11</last-edited> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="ProjectLibrariesConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="ScopeChooserConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + </states> + </component> +</project> \ No newline at end of file diff --git a/tp1/.project b/tp1/.project new file mode 100644 index 0000000000000000000000000000000000000000..9cdc304aeed6192610fc8e7dcbb7e84786b36b86 --- /dev/null +++ b/tp1/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>tp1</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/tp1/Cohort.class b/tp1/Cohort.class new file mode 100644 index 0000000000000000000000000000000000000000..b6a903a71cb9b78a81ca3acaa9ea4ca7404d3474 Binary files /dev/null and b/tp1/Cohort.class differ diff --git a/tp1/Cohort.java b/tp1/Cohort.java old mode 100644 new mode 100755 index e199e790e8c0dad4a95033147e150e6a0a1a8fd6..87551ebbb2cefb85e6430151114837b161bea287 --- a/tp1/Cohort.java +++ b/tp1/Cohort.java @@ -24,6 +24,7 @@ public class Cohort { * @param student the student to be added to the cohort */ public void addStudent(Student student){ + students.add(student); } /** @@ -31,6 +32,7 @@ public class Cohort { * @return the list of students of the cohort. */ public List<Student> getStudents(){ + return students; } /** @@ -38,9 +40,16 @@ public class Cohort { * grade. */ public void printStudentsResults(){ + System.out.println(name); + for (Student Student : students){ + Student.printResults(); + } + + } private void printName(){ + System.out.println(name); } /** @@ -49,5 +58,64 @@ public class Cohort { */ @Override public String toString() { + return name; + } + + + public int numberOfStudentsThatValidated(){ + int i = 0; + for (Student Student : students){ + Grade averageGrade = Student.getAverageGrade(); + if (averageGrade.getValue() >= 10) + i += 1; + } + + return i; + } + + + public int numberOfAbsent(){ + int i = 0; + for (Student Student : students){ + Grade averageGrade = Student.getAverageGrade(); + if (averageGrade.isAbsent()) + i += 1; + } + return i; + } + + public double noteMax(){ + double noteMax = 0; + for (Student Student : students){ + Grade grade = Student.getAverageGrade(); + if (grade.getValue() > noteMax) + noteMax = grade.getValue(); + } + return noteMax; + } + + + public double noteMin(){ + double noteMin = 20; + for (Student Student : students){ + Grade grade = Student.getAverageGrade(); + if (grade.getValue() < noteMin) + noteMin = grade.getValue(); + } + return noteMin; + } + + + public Grade AverageCohort() { + double i = 0; + double sum = 0; + for (Student Student : students){ + if(Student.getAverageGrade().isAbsent()) + sum =+ 0; + else + sum += Student.getAverageGrade().getValue(); + i += 1; + } + return new Grade(sum/i); } } diff --git a/tp1/Grade.class b/tp1/Grade.class new file mode 100644 index 0000000000000000000000000000000000000000..5d01f09dc0b857add1a90e872bc94a2d208dc2b0 Binary files /dev/null and b/tp1/Grade.class differ diff --git a/tp1/Grade.java b/tp1/Grade.java old mode 100644 new mode 100755 index f25893ad124c14486ec41755c07bd60cd3a9148b..03cbd1de726e502ef2c60cc24b1edac23e39fd05 --- a/tp1/Grade.java +++ b/tp1/Grade.java @@ -10,6 +10,8 @@ public class Grade { */ private static final int MAXIMUM_GRADE = 20; private final double value; + private final boolean isAbsent; + /** * Constructs a grade with a value equals to the specified {@code value}. @@ -17,10 +19,18 @@ public class Grade { * @param value the value of the constructed grade */ - public Grade(double value) { + public Grade(double value, boolean isAbsent) { this.value = value; + this.isAbsent = isAbsent; } - + + public Grade(double value) { + this(value, false); + } + + public Grade() { + this(0., true); +} /** * Returns the value of the grade as a double. * @@ -28,6 +38,14 @@ public class Grade { */ public double getValue() { + return value; + } + + + public boolean isAbsent(){ + return isAbsent; + + } /** @@ -36,6 +54,9 @@ public class Grade { */ @Override public String toString() { + if (isAbsent) + return "ABS"; + return value + "/20"; } /** @@ -46,6 +67,14 @@ public class Grade { * @return a grade corresponding to the mean of grade in {@code grades} */ public static Grade averageGrade(List<Grade> grades){ + double sum = 0; + double i = 0; + for (Grade Grade : grades) { + sum += Grade.value; + i += 1; + } + Grade average = new Grade(sum / i); + return average; } /** @@ -74,4 +103,6 @@ public class Grade { long temp = Double.doubleToLongBits(value); return (int) (temp ^ (temp >>> 32)); } + + } diff --git a/tp1/Main.class b/tp1/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..4587c3cc7c7b26b237eae1213a7b60a2bc86bd52 Binary files /dev/null and b/tp1/Main.class differ diff --git a/tp1/Main.java b/tp1/Main.java old mode 100644 new mode 100755 index 185824dd55c4a42adf72eae2a8f98e761dda9b8e..3aba635d3448a00d420a6ac4bfef719dbd6ffdb0 --- a/tp1/Main.java +++ b/tp1/Main.java @@ -1,4 +1,17 @@ public class Main { public static void main(String[] args){ + Student Teo = new Student("Teo","Blaise -- Kaplanski"); + Student Momo = new Student("Mohamed", "Hanouche"); + + Teo.addResult("Programmation 2", new Grade(20)); + Teo.addResult("Structures discrètes", new Grade(20)); + Momo.addResult("Programmation 2", new Grade(15)); + Momo.addResult("Structures discrètes", new Grade(7)); + + Cohort L2info = new Cohort("L2 Informatique"); + L2info.addStudent(Teo); + L2info.addStudent(Momo); + + L2info.printStudentsResults(); } } diff --git a/tp1/Student.class b/tp1/Student.class new file mode 100644 index 0000000000000000000000000000000000000000..056f53ef8a01b3775ad9f06b557cfe9920c8d4cd Binary files /dev/null and b/tp1/Student.class differ diff --git a/tp1/Student.java b/tp1/Student.java old mode 100644 new mode 100755 index 9898a666f45ccd49189150bba98d8aa44f45912e..a7cc11f6f4b237474c53ea6240a41324e4c3084a --- a/tp1/Student.java +++ b/tp1/Student.java @@ -31,7 +31,12 @@ public class Student { * @param grade the grade of the added result */ public void addResult(String teachingUnitName, Grade grade){ + results.add(new TeachingUnitResult(teachingUnitName, grade)); } + + public List<TeachingUnitResult> getResults() { + return results; + } /** * Returns a string representation of the student in the format first name last name. @@ -39,6 +44,7 @@ public class Student { */ @Override public String toString() { + return firstName +" "+ lastName; } @@ -48,6 +54,11 @@ public class Student { * @return the grades of the student */ public List<Grade> getGrades(){ + List<Grade> grades = new ArrayList<>(); + for (TeachingUnitResult result : results ) { + grades.add(result.getGrade()); + } + return grades; } /** @@ -56,6 +67,7 @@ public class Student { * @return the average grade of the student */ public Grade getAverageGrade() { + return Grade.averageGrade(getGrades()); } @Override @@ -81,12 +93,21 @@ public class Student { * the average grade of the student. */ public void printResults(){ + printName(); + for (TeachingUnitResult result : results) { + System.out.println(result.toString()); + } + printAverageGrade(); + System.out.println(); + } private void printName() { + System.out.println(toString()); } private void printAverageGrade() { + System.out.println("note moyenne :" + getAverageGrade()); } } diff --git a/tp1/TeachingUnit.class b/tp1/TeachingUnit.class new file mode 100644 index 0000000000000000000000000000000000000000..66c5d8fbffcff885445a09ac8833effbd97b5779 Binary files /dev/null and b/tp1/TeachingUnit.class differ diff --git a/tp1/TeachingUnit.java b/tp1/TeachingUnit.java new file mode 100644 index 0000000000000000000000000000000000000000..33bb77cd6400e8bc6b1a33d067b4a5d2b486e1bf --- /dev/null +++ b/tp1/TeachingUnit.java @@ -0,0 +1,24 @@ +import java.util.List; + +public class TeachingUnit { + private TeachingUnitResult UE; + private int Coef; + + + public TeachingUnit (TeachingUnitResult UE, int Coef) { + this.UE = UE; + this.Coef = Coef; + } + + public Grade averageGradeCoef(List<TeachingUnit> teachingUnit) { + double sum = 0; + double i = 0; + for (TeachingUnit TeachingUnit : teachingUnit ) { + double grade = TeachingUnit.UE.getGrade().getValue(); + sum += grade; + i += Coef; + } + Grade averageCoef = new Grade(sum / i); + return averageCoef; + } +} diff --git a/tp1/TeachingUnitResult.class b/tp1/TeachingUnitResult.class new file mode 100644 index 0000000000000000000000000000000000000000..d9033c3f85af543e368a69a148d625aa9fb83598 Binary files /dev/null and b/tp1/TeachingUnitResult.class differ diff --git a/tp1/TeachingUnitResult.java b/tp1/TeachingUnitResult.java old mode 100644 new mode 100755 index c052586a62e9513c55979121bb6ff8b67972fc71..eebf876df1cfae3551b09748dcc49ff2c9c422b8 --- a/tp1/TeachingUnitResult.java +++ b/tp1/TeachingUnitResult.java @@ -26,6 +26,7 @@ public class TeachingUnitResult { * @return the grade associated to the result */ public Grade getGrade() { + return grade; } /** @@ -34,5 +35,6 @@ public class TeachingUnitResult { */ @Override public String toString() { + return teachingUnitName + " : " + grade; } } diff --git a/tp1/TestCohort.class b/tp1/TestCohort.class new file mode 100644 index 0000000000000000000000000000000000000000..69adf5c2fe6f4dc7b79cc286dc40a39b91ff33a5 Binary files /dev/null and b/tp1/TestCohort.class differ diff --git a/tp1/TestCohort.java b/tp1/TestCohort.java new file mode 100644 index 0000000000000000000000000000000000000000..3846e1385eb99935bb8c202220226d2e49543e1e --- /dev/null +++ b/tp1/TestCohort.java @@ -0,0 +1,66 @@ +import java.util.ArrayList; +import java.util.List; + +public class TestCohort { + public static void main(String[] args){ + TestCohort test = new TestCohort(); + if(test.testaddStudent() == true) + System.out.println("testCohort : correct"); + else + System.out.println("testCohort : incorrect"); + + if(test.testToString() == true) + System.out.println("testToString : correct"); + else + System.out.println("testToString : incorrect"); + + if(test.testGetStudents() == true) + System.out.println("testGetStudents : correct"); + else + System.out.println("testGetStudents : incorrect"); + + + + } + + public boolean testaddStudent(){ + Student Mayombo = new Student("le mimi", "des mimis"); + Cohort Programmation2 = new Cohort("Programmation 2"); + Programmation2.addStudent(Mayombo); + List<Student> list = new ArrayList<Student>(); + list.add(new Student("le mimi", "des mimis")); + + if(Programmation2.getStudents().equals(list)) + return true; + else + System.out.println(list); + System.out.println(Programmation2.getStudents()); + return false; + } + + public boolean testToString(){ + Cohort binks = new Cohort("binks"); + if (binks.toString().equals("binks")) + return true; + else + + return false; + + } + + public boolean testGetStudents(){ + Student LUV = new Student("Lil","Uzi"); + Cohort Zoom = new Cohort("zoom"); + Zoom.addStudent(LUV); + List<Student> get = new ArrayList<Student>(); + get.add(new Student("Lil","Uzi")); + if(Zoom.getStudents().equals(get)) + return true; + else + return false; + + } + + + +} diff --git a/tp1/TestGrade.class b/tp1/TestGrade.class new file mode 100644 index 0000000000000000000000000000000000000000..03883118515ae73ef09968c5cefd1d723f3f0b28 Binary files /dev/null and b/tp1/TestGrade.class differ diff --git a/tp1/TestGrade.java b/tp1/TestGrade.java old mode 100644 new mode 100755 diff --git a/tp1/TestStudent.class b/tp1/TestStudent.class new file mode 100644 index 0000000000000000000000000000000000000000..d7a8d047261c12fd1766dbaccf74cc7cc00844de Binary files /dev/null and b/tp1/TestStudent.class differ diff --git a/tp1/TestStudent.java b/tp1/TestStudent.java new file mode 100644 index 0000000000000000000000000000000000000000..2e719fa96294999731bd281534619e5e04569558 --- /dev/null +++ b/tp1/TestStudent.java @@ -0,0 +1,87 @@ +import java.util.ArrayList; +import java.util.List; + +public class TestStudent { + public static void main(String[] args){ + TestStudent test = new TestStudent(); + if(test.testaddResult() == true) + System.out.println("testAddResult : correct"); + else + System.out.println("testAddResult : incorrect"); + + if(test.testToString() == true) + System.out.println("testToString : correct"); + else + System.out.println("testToString : incorrect"); + + if(test.testGetGrades() == true) + System.out.println("testGetGrades : correct"); + else + System.out.println("testGetGrades : incorrect"); + + if(test.testgetAverageGrade() == true) + System.out.println("testAverageGrades : correct"); + else + System.out.println("testAverageGrades : incorrect"); + + + + } + + + + public boolean testaddResult(){ + Student Freeze = new Student("Freeze", "Corleone"); + Freeze.addResult("LMF", new Grade(19)); + List<TeachingUnitResult> list = new ArrayList<TeachingUnitResult>(); + list.add(new TeachingUnitResult("LMF", new Grade(19))); + + if(Freeze.getResults().equals(list)) + return true; + else + System.out.println(list); + System.out.println(Freeze.getResults()); + return false; + } + + + public boolean testToString(){ + Student PopSmoke = new Student("Pop", "Smoke"); + String studentName = PopSmoke.toString(); + if(studentName.equals("Pop Smoke")) + return true; + else + System.out.println(PopSmoke); + return false; + + } + + public boolean testGetGrades(){ + Student Blueface = new Student("Blueface", "Baby"); + Blueface.addResult("L.A", new Grade(12)); + List<Grade> Bgrade = new ArrayList<>(); + Bgrade.add(new Grade(12)); + if(Blueface.getGrades().equals(Bgrade)) + return true; + else + + return false; + + + } + + public boolean testgetAverageGrade(){ + Student Sosa = new Student("Chief","Keef"); + Sosa.addResult("Chiraq", new Grade(3)); + Sosa.addResult("Drill", new Grade(20)); + Grade average = Sosa.getAverageGrade(); + if(average.getValue() == 11.5) + return true; + else + return false; + } + + + + +} diff --git a/tp1/TestTeachingUnitResult.class b/tp1/TestTeachingUnitResult.class new file mode 100644 index 0000000000000000000000000000000000000000..94f0712dd0cc882f7c1bd5e35423f1f56f2438c1 Binary files /dev/null and b/tp1/TestTeachingUnitResult.class differ diff --git a/tp1/TestTeachingUnitResult.java b/tp1/TestTeachingUnitResult.java new file mode 100644 index 0000000000000000000000000000000000000000..bb9a84387f7c6bdea122cbf76504b2eec17f9be2 --- /dev/null +++ b/tp1/TestTeachingUnitResult.java @@ -0,0 +1,40 @@ + +public class TestTeachingUnitResult { + public static void main(String[] args){ + TestTeachingUnitResult test = new TestTeachingUnitResult(); + if(test.testgetGrade() == true) + System.out.println("testGrade : correct"); + else + System.out.println("testGrade : incorrect"); + + if(test.testToString() == true) + System.out.println("testToString : correct"); + else + System.out.println("testToString : incorrect"); + + + } + + public boolean testgetGrade(){ + TeachingUnitResult grade = new TeachingUnitResult("",new Grade(12.5)); + Grade val = grade.getGrade(); + double val1 = val.getValue(); + if(val1 == 12.5) + return true; + else + System.out.println(val); + System.out.println(new Grade(12.5)); + return false; + } + + public boolean testToString(){ + TeachingUnitResult teachingUnitResult = new TeachingUnitResult("Programmation 2", new Grade(13.7)); + String teachnigUnitResultString = teachingUnitResult.toString(); + if(teachnigUnitResultString.equals("Programmation 2 : 13.7/20")) + return true; + else + System.out.println(teachnigUnitResultString); + return false; + } + +}