update
This commit is contained in:
BIN
DEV/DEV2.3/TP02_JUnit/ex2/Largest.class
Normal file
BIN
DEV/DEV2.3/TP02_JUnit/ex2/Largest.class
Normal file
Binary file not shown.
18
DEV/DEV2.3/TP02_JUnit/ex2/Largest.java
Normal file
18
DEV/DEV2.3/TP02_JUnit/ex2/Largest.java
Normal 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;
|
||||
}
|
||||
}
|
||||
18
DEV/DEV2.3/TP02_JUnit/ex2/Largest.java~
Normal file
18
DEV/DEV2.3/TP02_JUnit/ex2/Largest.java~
Normal 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;
|
||||
}
|
||||
}
|
||||
BIN
DEV/DEV2.3/TP02_JUnit/ex2/TestLargest.class
Normal file
BIN
DEV/DEV2.3/TP02_JUnit/ex2/TestLargest.class
Normal file
Binary file not shown.
10
DEV/DEV2.3/TP02_JUnit/ex2/TestLargest.java
Normal file
10
DEV/DEV2.3/TP02_JUnit/ex2/TestLargest.java
Normal 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}));
|
||||
}
|
||||
}
|
||||
10
DEV/DEV2.3/TP02_JUnit/ex2/TestLargest.java~
Normal file
10
DEV/DEV2.3/TP02_JUnit/ex2/TestLargest.java~
Normal 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}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user