Skip to content
Snippets Groups Projects
Commit 11b6c68b authored by Teo Blaise Kaplanski's avatar Teo Blaise Kaplanski
Browse files

test

parent b9bfe82c
No related branches found
No related tags found
No related merge requests found
Showing with 535 additions and 2 deletions
<?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>
<component name="ProjectDictionaryState">
<dictionary name="teobk" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>
\ No newline at end of file
<?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
<?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
<?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
<?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&#9;" />
<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
<?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>
File added
tp1/Cohort.java 100644 → 100755
...@@ -24,6 +24,7 @@ public class Cohort { ...@@ -24,6 +24,7 @@ public class Cohort {
* @param student the student to be added to the cohort * @param student the student to be added to the cohort
*/ */
public void addStudent(Student student){ public void addStudent(Student student){
students.add(student);
} }
/** /**
...@@ -31,6 +32,7 @@ public class Cohort { ...@@ -31,6 +32,7 @@ public class Cohort {
* @return the list of students of the cohort. * @return the list of students of the cohort.
*/ */
public List<Student> getStudents(){ public List<Student> getStudents(){
return students;
} }
/** /**
...@@ -38,9 +40,16 @@ public class Cohort { ...@@ -38,9 +40,16 @@ public class Cohort {
* grade. * grade.
*/ */
public void printStudentsResults(){ public void printStudentsResults(){
System.out.println(name);
for (Student Student : students){
Student.printResults();
}
} }
private void printName(){ private void printName(){
System.out.println(name);
} }
/** /**
...@@ -49,5 +58,64 @@ public class Cohort { ...@@ -49,5 +58,64 @@ public class Cohort {
*/ */
@Override @Override
public String toString() { 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);
} }
} }
File added
tp1/Grade.java 100644 → 100755
...@@ -10,6 +10,8 @@ public class Grade { ...@@ -10,6 +10,8 @@ public class Grade {
*/ */
private static final int MAXIMUM_GRADE = 20; private static final int MAXIMUM_GRADE = 20;
private final double value; private final double value;
private final boolean isAbsent;
/** /**
* Constructs a grade with a value equals to the specified {@code value}. * Constructs a grade with a value equals to the specified {@code value}.
...@@ -17,10 +19,18 @@ public class Grade { ...@@ -17,10 +19,18 @@ public class Grade {
* @param value the value of the constructed grade * @param value the value of the constructed grade
*/ */
public Grade(double value) { public Grade(double value, boolean isAbsent) {
this.value = value; 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. * Returns the value of the grade as a double.
* *
...@@ -28,6 +38,14 @@ public class Grade { ...@@ -28,6 +38,14 @@ public class Grade {
*/ */
public double getValue() { public double getValue() {
return value;
}
public boolean isAbsent(){
return isAbsent;
} }
/** /**
...@@ -36,6 +54,9 @@ public class Grade { ...@@ -36,6 +54,9 @@ public class Grade {
*/ */
@Override @Override
public String toString() { public String toString() {
if (isAbsent)
return "ABS";
return value + "/20";
} }
/** /**
...@@ -46,6 +67,14 @@ public class Grade { ...@@ -46,6 +67,14 @@ public class Grade {
* @return a grade corresponding to the mean of grade in {@code grades} * @return a grade corresponding to the mean of grade in {@code grades}
*/ */
public static Grade averageGrade(List<Grade> 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 { ...@@ -74,4 +103,6 @@ public class Grade {
long temp = Double.doubleToLongBits(value); long temp = Double.doubleToLongBits(value);
return (int) (temp ^ (temp >>> 32)); return (int) (temp ^ (temp >>> 32));
} }
} }
File added
tp1/Main.java 100644 → 100755
public class Main { public class Main {
public static void main(String[] args){ 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();
} }
} }
File added
...@@ -31,6 +31,11 @@ public class Student { ...@@ -31,6 +31,11 @@ public class Student {
* @param grade the grade of the added result * @param grade the grade of the added result
*/ */
public void addResult(String teachingUnitName, Grade grade){ public void addResult(String teachingUnitName, Grade grade){
results.add(new TeachingUnitResult(teachingUnitName, grade));
}
public List<TeachingUnitResult> getResults() {
return results;
} }
/** /**
...@@ -39,6 +44,7 @@ public class Student { ...@@ -39,6 +44,7 @@ public class Student {
*/ */
@Override @Override
public String toString() { public String toString() {
return firstName +" "+ lastName;
} }
...@@ -48,6 +54,11 @@ public class Student { ...@@ -48,6 +54,11 @@ public class Student {
* @return the grades of the student * @return the grades of the student
*/ */
public List<Grade> getGrades(){ 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 { ...@@ -56,6 +67,7 @@ public class Student {
* @return the average grade of the student * @return the average grade of the student
*/ */
public Grade getAverageGrade() { public Grade getAverageGrade() {
return Grade.averageGrade(getGrades());
} }
@Override @Override
...@@ -81,12 +93,21 @@ public class Student { ...@@ -81,12 +93,21 @@ public class Student {
* the average grade of the student. * the average grade of the student.
*/ */
public void printResults(){ public void printResults(){
printName();
for (TeachingUnitResult result : results) {
System.out.println(result.toString());
}
printAverageGrade();
System.out.println();
} }
private void printName() { private void printName() {
System.out.println(toString());
} }
private void printAverageGrade() { private void printAverageGrade() {
System.out.println("note moyenne :" + getAverageGrade());
} }
} }
File added
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;
}
}
File added
...@@ -26,6 +26,7 @@ public class TeachingUnitResult { ...@@ -26,6 +26,7 @@ public class TeachingUnitResult {
* @return the grade associated to the result * @return the grade associated to the result
*/ */
public Grade getGrade() { public Grade getGrade() {
return grade;
} }
/** /**
...@@ -34,5 +35,6 @@ public class TeachingUnitResult { ...@@ -34,5 +35,6 @@ public class TeachingUnitResult {
*/ */
@Override @Override
public String toString() { public String toString() {
return teachingUnitName + " : " + grade;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment