Skip to content

Commit

Permalink
#2 Fix compile issues
Browse files Browse the repository at this point in the history
  • Loading branch information
iuresti committed Apr 19, 2017
1 parent 1ebb025 commit 8b947a9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
package devslp.designpatterns.TemplateMethod.SortStrategyExample;

public class DoubleSortHandler implements SortHandler {
private double [] array;
private Double[] array;

public void setArray(Object [] theArray)
{
array = new double[theArray.length];
for (int i = 0; i < theArray.length ; i++) {
array[i] = (double)theArray[i];
}
public void setArray(Object[] theArray) {
array = new Double[theArray.length];

System.arraycopy(theArray, 0, array, 0, theArray.length);
}

@Override
public Object[] getArray() {
return array;
}

public int getLength()
{
public int getLength() {
return array.length;
}

public boolean outOfOrder(int index) {
return (array[index-1] > array[index]);
return (array[index - 1] > array[index]);
}

public void swap(int index)
{
double temp = array[index-1];
array[index-1] = array[index];
public void swap(int index) {
double temp = array[index - 1];
array[index - 1] = array[index];
array[index] = temp;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,29 @@
having no dependency whatever on the bubble sort implementation.
*/
public class IntSortHandler implements SortHandler {
private int [] array;
private Integer[] array;

public void setArray(Object [] theArray)
{
array = new int[theArray.length];
for (int i = 0; i < theArray.length ; i++) {
array[i] = (int)theArray[i];
}
public void setArray(Object[] theArray) {
array = new Integer[theArray.length];

System.arraycopy(theArray, 0, array, 0, theArray.length);
}

public Object[] getArray() {
return array;
}

public int getLength()
{
public int getLength() {
return array.length;
}

public boolean outOfOrder(int index) {
return (array[index-1] > array[index]);
return (array[index - 1] > array[index]);
}

public void swap(int index)
{
int temp = array[index-1];
array[index-1] = array[index];
public void swap(int index) {
int temp = array[index - 1];
array[index - 1] = array[index];
array[index] = temp;
}
}

0 comments on commit 8b947a9

Please sign in to comment.