Skip to content

Commit 95092b9

Browse files
author
codelogicws
committed
implementing Shuffle
1 parent 9ada4ab commit 95092b9

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package ws.codelogic.algorithms.shuffle;
2+
3+
public class Shuffler {
4+
5+
public int[] shuffle(int[] sorted) {
6+
return new int[4];
7+
}
8+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package ws.codelogic.algorithms.shuffle;
2+
3+
import static org.junit.Assert.*;
4+
import org.junit.Before;
5+
import org.junit.Test;
6+
7+
public class ShufflerTest {
8+
9+
private Shuffler shuffler;
10+
private int[] sorted = {1,2,3,4,5,6,7,8,9};
11+
12+
@Before
13+
public void setup() {
14+
shuffler = new Shuffler();
15+
}
16+
17+
@Test
18+
public void testItemsAreNotInTheSortedOrderTheyWhereSentIn() {
19+
int[] shuffled = shuffler.shuffle(sorted);
20+
assertFalse(arraysNotEqual(shuffled, sorted));
21+
}
22+
23+
private boolean arraysNotEqual(int[] array1, int[] array2){
24+
boolean arraysEqual = true;
25+
if(array1.length != array2.length){
26+
arraysEqual = false;
27+
}else{
28+
for(int i=0;i<array1.length;i++){
29+
if(array1[i] != array2[i]){
30+
arraysEqual = false;
31+
break;
32+
}
33+
}
34+
}
35+
return arraysEqual;
36+
}
37+
}

src/ws/codelogic/test/TestSuite.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import ws.codelogic.algorithms.Stack.LinkStackTest;
77
import ws.codelogic.algorithms.arithmetic.evaluation.DijkstrasTwoStackTest;
88
import ws.codelogic.algorithms.search.SearchTest;
9+
import ws.codelogic.algorithms.shuffle.Shuffler;
910
import ws.codelogic.algorithms.sort.InsertionSortTest;
1011
import ws.codelogic.algorithms.sort.SelectionSortTest;
1112
import ws.codelogic.algorithms.sort.ShellSort;
@@ -21,6 +22,7 @@
2122
ShellSortTest.class,
2223
DijkstrasTwoStackTest.class,
2324
ArrayStackTest.class,
25+
// Shuffler.class,
2426
LinkStackTest.class})
2527
public class TestSuite {
2628
}

0 commit comments

Comments
 (0)