-
Notifications
You must be signed in to change notification settings - Fork 13
Implementation #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)){ | ||
| 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]; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
| } | ||
| 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); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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--){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
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