import java.util.Arrays; import java.util.Collections; public class Kata { public static int findMax(int[] my_array) { // Write a method that returns the largest integer in the list. // You can assume that the list has at least one element. Arrays.sort(my_array); return my_array[my_array.length-1]; } }
- import java.util.Arrays;
- import java.util.Collections;
- public class Kata {
- public static int findMax(int[] my_array) {
- // Write a method that returns the largest integer in the list.
- // You can assume that the list has at least one element.
return 7;- Arrays.sort(my_array);
- return my_array[my_array.length-1];
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; class SolutionTest { @Test void testSomething() { assertEquals(Kata.findMax(new int[]{4, 5, 6, 7}), 7); } @Test void testSomethingElse() { assertEquals(Kata.findMax(new int[]{4, 5, 6, 7, 12}), 12); } @Test void testSomethingNew() { assertEquals(Kata.findMax(new int[]{4, 5, 6, 7, 12, 4}), 12); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
// TODO: Write more tests to prove your code bleow- class SolutionTest {
- @Test
- void testSomething() {
- assertEquals(Kata.findMax(new int[]{4, 5, 6, 7}), 7);
- }
- @Test
- void testSomethingElse() {
- assertEquals(Kata.findMax(new int[]{4, 5, 6, 7, 12}), 12);
- }
- @Test
- void testSomethingNew() {
- assertEquals(Kata.findMax(new int[]{4, 5, 6, 7, 12, 4}), 12);
- }
- }