[O] Optimize getGP
This commit is contained in:
+7
-16
@@ -85,26 +85,17 @@ export class GPAUtils
|
|||||||
* @param course Course
|
* @param course Course
|
||||||
* @param letterGrade Letter grade
|
* @param letterGrade Letter grade
|
||||||
*/
|
*/
|
||||||
public static getGP(course: Course, letterGrade?: string): number
|
public static getGP(course: Course, letterGrade: string): number
|
||||||
{
|
{
|
||||||
// Find the GPA for this course.
|
// Get scale
|
||||||
for (let scale of this.SCALE)
|
let scale = this.findScale(letterGrade);
|
||||||
{
|
|
||||||
// Letter grades are the same
|
|
||||||
if (scale[this.LETTER] == letterGrade)
|
|
||||||
{
|
|
||||||
// Get grade and add it
|
|
||||||
let grade = <number> scale[this.GPA];
|
|
||||||
|
|
||||||
// Add scaleUp if not failed.
|
// No scale
|
||||||
if (grade != 0) grade += course.scaleUp;
|
if (scale == undefined) return -1;
|
||||||
|
|
||||||
// That's it
|
// Add scaleUp if not failed.
|
||||||
return grade;
|
return scale.gp == 0 ? 0 : scale.gp + course.scaleUp;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user