Commit fe1e03c5 authored by jack.templeman's avatar jack.templeman

initial

parent 7805f22d
Pipeline #227 failed with stages
...@@ -7,7 +7,7 @@ public class AssessmentPartOne { ...@@ -7,7 +7,7 @@ public class AssessmentPartOne {
// Debug this method so it passes the unit test. // Debug this method so it passes the unit test.
// Add comments beside any changes you make // Add comments beside any changes you make
if (num1<num2) if (num1>num2) //switched < to >
{ {
if (num3>num1) if (num3>num1)
{ {
...@@ -26,7 +26,7 @@ public class AssessmentPartOne { ...@@ -26,7 +26,7 @@ public class AssessmentPartOne {
} }
else else
{ {
return num2 return num2; //added semicolon
} }
} }
} }
...@@ -43,9 +43,38 @@ public class AssessmentPartOne { ...@@ -43,9 +43,38 @@ public class AssessmentPartOne {
// You should comment your code explaining what each part does // You should comment your code explaining what each part does
int sumOfSquares = 0; int sumOfSquares = 0;
int negativeAnswer = -1; //This will be returned if the range starts as a negative
if (start < 0)
{
return negativeAnswer; //This returns "-1" if the range starts as a negative
}
if (end - start == 1)
{
return negativeAnswer; //This returns "-1" if there are no values between start and end
}
if (start > end)
{
return negativeAnswer; //This returns "-1" if the end value is larger than the start
}
else
{ for (int a = start +1; a < end; a++) // For loop will add all terms between start and end int
{
sumOfSquares += a; // Adds each term to the sum value
}
}
return sumOfSquares; return sumOfSquares;
} }
} }
...@@ -40,5 +40,7 @@ class AssessmentPartOneTest { ...@@ -40,5 +40,7 @@ class AssessmentPartOneTest {
}) })
void testSumNumbersBetween(int num1, int num2, int sum) { void testSumNumbersBetween(int num1, int num2, int sum) {
assertEquals(sum, test.sumNumbersBetween(num1, num2)); assertEquals(sum, test.sumNumbersBetween(num1, num2));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment