Commit 797da417 authored by MaximumShast's avatar MaximumShast

work for assessment

parent b5940f18
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>
...@@ -7,9 +7,9 @@ public class AssessmentPartOne { ...@@ -7,9 +7,9 @@ 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) // made sure num2 is greater than num1
{ {
if (num3>num1) if (num3>num1) // made sure num1 is greater than num3
{ {
return num3; return num3;
} }
...@@ -20,13 +20,13 @@ public class AssessmentPartOne { ...@@ -20,13 +20,13 @@ public class AssessmentPartOne {
} }
else else
{ {
if (num3>num2) if (num3>num2) //made sure num2 is greater than num3
{ {
return num3; return num3;
} }
else else
{ {
return num2 return num2; // added semicolon to end the code
} }
} }
} }
...@@ -42,10 +42,36 @@ public class AssessmentPartOne { ...@@ -42,10 +42,36 @@ 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;
// Setting the int data type of the sumOfNumbers setting its value to 0
int SumOfNumbers = 0;
return sumOfSquares; //This part of the code states if the start is greater than the end value it will set the sumOfNumbers as -1 as stated in the instructions and will then return this value
//If this is not the outcome it will then continue to the else if segment of the code
if(start > end) {
SumOfNumbers = -1;
return SumOfNumbers;
}
//This segment of code is to make sure that if the code starts at 0= or ends as a 0 it will set the sumOfNumbers as -1 and return this value
//If this is not the case it will carry on to the next else if statement
else if(start < 0 || end <= 0) {
SumOfNumbers = -1;
return SumOfNumbers;
}
//This segment of the code states that if the start of the code plus 1 is equal to the of the code it will return the sumOfNumbers as equal -1
//If this is not the case it will then go to the while section of the code
else if(start + 1 == end) {
SumOfNumbers = -1;
return SumOfNumbers;
}
//This section of the code is states while the start of the code is less than end-1 it will increment the start value. It will then start the sumOfNumbers. It then returns this value.
//This segment of the code will continue to run this section until the start value is equal to the end value of -1
while(start < end -1) {
++start;
SumOfNumbers+=start;
}
return SumOfNumbers;
} }
} }
...@@ -8,7 +8,7 @@ import org.junit.jupiter.params.provider.CsvSource; ...@@ -8,7 +8,7 @@ import org.junit.jupiter.params.provider.CsvSource;
class AssessmentPartOneTest { class AssessmentPartOneTest {
public static AssessmentPartOne test; public static AssessmentPartOneTest test;
@BeforeAll @BeforeAll
static void setUpBeforeClass() throws Exception { static void setUpBeforeClass() throws Exception {
......
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