Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/main/java/com/oracle/arrays/impl/MultidimensionalImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,27 @@
public class MultidimensionalImpl implements Multidimensional {
@Override
public Posicion getPosition(String[][] datos, String dato) {
Posicion pos = new Posicion(0, 0);
for(int i = 0; i < datos.length; i++){
for(int j = 0; j < datos[i].length;j++){
if(datos[i][j].equals(dato)){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

puedes tambien utilizar la creacion del objecto Posicion con new, esto solo te ahorra lineas codigo

pos.setX(i);
pos.setY(j);
return pos;
}
}
}

return null;


}

@Override
public String getData(String[][] datos, Posicion posicion) {
return null;
int x = posicion.getX();
int y = posicion.getY();

return datos[x][y];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

puedes usar los getter dentro del array en lugar de asignacion de variables

}
}
15 changes: 14 additions & 1 deletion src/main/java/com/oracle/arrays/impl/UnidimensionalImpl.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
package com.oracle.arrays.impl;

import java.util.Arrays;

import com.oracle.arrays.Unidimensional;

public class UnidimensionalImpl implements Unidimensional {
@Override
public void ordenamiento(int[] arr) {
Arrays.sort(arr);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buen uso de herramientas existentes

}

@Override
public int[] ordenamientoReversa(int[] arr) {
return null;
Arrays.sort(arr);
int[] arrcopy = new int[arr.length];

int counter = 0;
for(int i = arr.length-1; i >= 0 ;i--){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

puedes volver a usar Arrays.sort() pero usando un comparator, que puedes pasar como parametro

arrcopy[counter] = arr[i];
counter++;
}

return arrcopy;
}
}