This commit is contained in:
2023-10-23 13:23:36 +02:00
parent 667dae6f1a
commit 322b22f9bf
5711 changed files with 72953 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,18 @@
public class Largest {
/**
* Return the largest element in a list.
*
* @param list A list of integers
* @return The largest number in the given list
*/
public static int largest(int[] list) {
int index, max=Integer.MIN_VALUE;
for (index = 0; index <= list.length-1; index++) {
if (list[index] > max) {
max = list[index];
}
}
return max;
}
}

View File

@@ -0,0 +1,18 @@
public class Largest {
/**
* Return the largest element in a list.
*
* @param list A list of integers
* @return The largest number in the given list
*/
public static int largest(int[] list) {
int index, max=Integer.MIN_VALUE;
for (index = 0; index <= list.length-1; index++) {
if (list[index] > max) {
max = list[index];
}
}
return max;
}
}

Binary file not shown.

View File

@@ -0,0 +1,10 @@
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class TestLargest {
@Test
public void testSimple() {
assertEquals(12, Largest.largest(new int[] {9,8,7,12}));
}
}

View File

@@ -0,0 +1,10 @@
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class TestLargest {
@Test
public void testSimple() {
assertEquals(12, Largest.largest(new int[] {9,8,7,12}));
}
}