Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
G2_MSAYIF_BASSEM_G2_LE_HAIDANG TP1-TP2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MSAYIF Bassem
G2_MSAYIF_BASSEM_G2_LE_HAIDANG TP1-TP2
Commits
e93f9d5a
Commit
e93f9d5a
authored
4 years ago
by
MSAYIF Bassem
Browse files
Options
Downloads
Patches
Plain Diff
Updated Grade Class
Implémentation des méthodes toString, getValue et averageGrade.
parent
b9bfe82c
Branches
Branches containing commit
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tp1/Grade.java
+11
-0
11 additions, 0 deletions
tp1/Grade.java
with
11 additions
and
0 deletions
tp1/Grade.java
+
11
−
0
View file @
e93f9d5a
...
...
@@ -28,6 +28,7 @@ public class Grade {
*/
public
double
getValue
()
{
return
value
;
}
/**
...
...
@@ -36,6 +37,7 @@ public class Grade {
*/
@Override
public
String
toString
()
{
return
getValue
()
+
"/20"
;
}
/**
...
...
@@ -46,6 +48,15 @@ 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
total
=
0
;
if
(!
grades
.
isEmpty
())
{
for
(
Grade
grade
:
grades
)
{
sum
+=
grade
.
value
;
}
total
=
sum
/
grades
.
size
();
}
return
new
Grade
(
total
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment