Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
StudiApp
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OST
SEProj
StudiApp
Merge requests
!13
Added PercentageConverter and AverageMarkConverter with tests
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Added PercentageConverter and AverageMarkConverter with tests
80_ValueConverters
into
master
Overview
3
Commits
3
Pipelines
2
Changes
6
Merged
Fabrice Bosshard
requested to merge
80_ValueConverters
into
master
2 years ago
Overview
3
Commits
3
Pipelines
2
Changes
6
Expand
0
0
Merge request reports
Compare
master
version 1
1a989387
2 years ago
master (base)
and
latest version
latest version
9330b36f
3 commits,
2 years ago
version 1
1a989387
2 commits,
2 years ago
6 files
+
166
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
StudiApp/StudiApp/Services/Converters/AverageMarkConverter.cs
0 → 100644
+
23
−
0
Options
using
StudiApp.Models
;
namespace
StudiApp.Services.Converters
{
public
static
class
AverageMarkConverter
{
public
static
double
MarksToAverage
(
List
<
Mark
>
marks
)
{
if
(
marks
.
Any
(
m
=>
m
.
Value
is
>
6.0
or
<
1.0
))
{
throw
new
ArgumentException
(
"A Value in the marks list is over 6.0 or under 1.0"
);
}
if
(
marks
.
Any
(
m
=>
m
.
Percentage
is
>
1.0
or
<
0.01
))
{
throw
new
ArgumentException
(
"A Percentage in the marks list is over 100% (1.0) or under 1% (0.01)"
);
}
var
average
=
marks
.
Sum
(
mark
=>
mark
.
Value
*
mark
.
Percentage
);
return
Math
.
Round
(
average
,
2
);
}
}
}