Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. cannot be applied to given types;
  2. [ERROR] required: int[]
  3. [ERROR] found: int,int,int,int
  4. reason: actual and formal argument lists differ in length
  5.  
  6. @Test
  7. public void whenTurnArrayWithEvenAmountOfElementsThenTurnedArray() {
  8. Turn turn = new Turn();
  9. int[] resultArray = turn.back(4, 1, 6, 2);
  10. int[] expectArray = turn.back(2, 6, 1, 4);
  11. assertThat(resultArray, is(expectArray));
  12. }
  13.  
  14. public int[] back(int[] array) {
  15. for (int i = 0; i < array.length / 2; i++) {
  16. int k = array[i];
  17. array[i] = array[array.length - i + 1];
  18. array[array.length - i + 1] = k;
  19. }
  20. return array;
  21. }
  22.  
  23. @Test
  24. public void whenTurnArrayWithEvenAmountOfElementsThenTurnedArray() {
  25. Turn turn = new Turn();
  26. int[] resultArray = turn.back(new int[] {4, 1, 6, 2});
  27. int[] expectArray = new int[] {2, 6, 1, 4};
  28. assertThat(resultArray, is(expectArray));
  29. }
  30.  
  31. public int[] back(int... array) {
  32. for (int i = 0; i < array.length / 2; i++) {
  33. int k = array[i];
  34. array[i] = array[array.length - i + 1];
  35. array[array.length - i + 1] = k;
  36. }
  37. return array;
  38. }
  39.  
  40. @Test
  41. public void whenTurnArrayWithEvenAmountOfElementsThenTurnedArray() {
  42. Turn turn = new Turn();
  43. int[] resultArray = turn.back(4, 1, 6, 2);
  44. int[] expectArray = new int[] {2, 6, 1, 4};
  45. assertThat(resultArray, is(expectArray));
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement