Question: public static int[] task1(int[] seq, int n) { int[] result = null; /* Your task is to implement this method, * so that running TestUtilities.java
public static int[] task1(int[] seq, int n) { int[] result = null; /* Your task is to implement this method, * so that running TestUtilities.java will pass all JUnit tests. * * Recall from Week 1's tutorial videos: * 1. No System.out.println statements should appear here. * Instead, an explicit, final `return` statement is placed for you. * 2. No Scanner operations should appear here (e.g., input.nextInt()). * Instead, refer to the input parameters of this method. * 3. Do not re-assign any of the parameter/input variables. */ // Your implementation of this method starts here.
int arraySize = seq.length; int [] Array = new int[arraySize]; if(arraySize == 0) { result = Array; }else { n %= arraySize; int starting = 0; starting = (arraySize - n)% arraySize;
for(int i = 1; i starting %= arraySize; result = Array; } } // Do not modify this return statement. return result; } can u modify this to pass these tests ASAP */ @Test public void test_task1_01() { int[] seq = {1, 2, 3, 4, 5}; int[] expected = {1, 2, 3, 4, 5}; assertArrayEquals(expected, Utilities.task1(seq, 0)); } @Test public void test_task1_02() { int[] seq = {1, 2, 3, 4, 5}; int[] expected = {2, 3, 4, 5, 1}; assertArrayEquals(expected, Utilities.task1(seq, 1)); } @Test public void test_task1_03() { int[] seq = {1, 2, 3, 4, 5}; int[] expected = {5, 1, 2, 3, 4}; assertArrayEquals(expected, Utilities.task1(seq, 4)); } @Test public void test_task1_04() { int[] seq = {1, 2, 3, 4, 5}; int[] expected = {4, 5, 1, 2, 3}; assertArrayEquals(expected, Utilities.task1(seq, 8)); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
