From 811eb582b8d0f9195978de8a2c232839198e58dc Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Wed, 1 Feb 2023 13:51:03 +0000 Subject: [PATCH] fixed overall score calculation --- src/main/java/com/r0r5chach/Competitor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/r0r5chach/Competitor.java b/src/main/java/com/r0r5chach/Competitor.java index bdb3aea..b049de9 100644 --- a/src/main/java/com/r0r5chach/Competitor.java +++ b/src/main/java/com/r0r5chach/Competitor.java @@ -103,12 +103,12 @@ public abstract class Competitor { public double getOverallScore() { double output = 0; for (int score: getScores()) { - output += Math.log(score); //get the sum of the natural log of the scores + if (Math.log(score) != Double.NEGATIVE_INFINITY) { + output += Math.log(score); //get the sum of the natural log of the scores + } } output /= 1.93; //divide the sum by 1.93 - if (output == Double.NEGATIVE_INFINITY) { - output = 0; - } + return Double.parseDouble(df.format(output)); //df.format() allows the scores to be formatted to 2 decimal places } /**