public class MultSorter {

  public static void main(String[] args) {
    System.out.println("Ordenamiento ascendente de enteros");
    int[] intArray= {5, 2, 8, 20, 15, 1, -5, 34};
    GenSorter sorter= new IntSorter(intArray);
    sorter.print();
    sorter.sort();
    sorter.print();

    System.out.println("Ordenamiento descendente de reales");
    double[] doubleArray= { 5.0, 10.0, -4.0, 15.0, 13.0, 46.0, -2.0};
    sorter= new DoubleSorterDesc(doubleArray);
    sorter.print();
    sorter.sort();
    sorter.print();

    // System.out.println("Ordenamiento descendente de enteros");
    // sorter= new IntSorterDesc(intArray);
    // sorter.print();
    // sorter.sort();
    // sorter.print();

    // System.out.println("Ordenamiento ascendente de strings");
    // String[] stringArray= {"pedro", "juan", "y", "diego"};
    // sorter= new StringSorter(stringArray);
    // sorter.print();
    // sorter.sort();
    // sorter.print();
  }
}

class IntSorter extends GenSorter {

  public int[] intArray;

  public IntSorter(int[] intArray) { 
    this.intArray= intArray;
  }

  public void swap(int i, int j) { // Redefinicion
    int k= intArray[i];
    intArray[i]= intArray[j];
    intArray[j]= k;
  }

  public int compare(int i, int j) { // Redefinicion
    if (intArray[i]<intArray[j]) return -1;
    else if (intArray[i]==intArray[j]) return 0;
    else return 1;
  }

  public int size() { return intArray.length; } // Redefinicion

  public void print() { // Redefinicion
    for(int i=0; i<size(); i++)
      System.out.print(intArray[i]+" ");
    System.out.println();
  }
}

class DoubleSorterDesc extends GenSorter {

  public double[] doubleArray;

  public DoubleSorterDesc(double[] doubleArray) { 
    this.doubleArray= doubleArray;
  }

  public void swap(int i, int j) { // Redefinicion
    double k= doubleArray[i];
    doubleArray[i]= doubleArray[j];
    doubleArray[j]= k;
  }

  public int compare(int i, int j) { // Redefinicion
    if (doubleArray[i]<doubleArray[j]) return 1;
    else if (doubleArray[i]==doubleArray[j]) return 0;
    else return -1;
  }

  public int size() { return doubleArray.length; } // Redefinicion

  public void print() { // Redefinicion
    for(int i=0; i<size(); i++)
      System.out.print(doubleArray[i]+" ");
    System.out.println();
  }
}

// class IntSorterDesc extends IntSorter {
//   ... defina un constructor para IntSorterDesc ...
//   ... redefina el metodo compare ...
// }

// class StringSorter extends GenSorter {
//   ... defina una variable de instancia para referenciar el arreglo ...
//   ... defina un constructor para StringSorter ...
//   ... redefina los metodos compare, swap, size y print ...
// }
