public class MatrizEquipos {
private Object[][] matriz;
public MatrizEquipos() {
matriz = new Object[20][10];
llenarMatriz();
}
public Object[][] getMatriz() {
return matriz;
}
private void llenarMatriz() {
matriz[0] = new Object[] {1, "America", 17, 8, 5, 1, 2, 10, 8, 2};
matriz[1] = new Object[] {2, "Nacional", 16, 8, 4, 0, 4, 15, 6, 9};
matriz[2] = new Object[] {3, "Millonarios", 16, 7, 5, 1, 1, 12, 8, 4};
matriz[3] = new Object[] {4, "Alianza", 15, 8, 4, 1, 3, 7, 4, 3};
matriz[4] = new Object[] {5, "Cali", 14, 8, 4, 2, 2, 11, 6, 5};
matriz[5] = new Object[] {6, "Patriotas", 12, 8, 3, 2, 3, 10, 7, 3};
matriz[6] = new Object[] {7, "Tolima", 11, 8, 3, 3, 2, 10, 5, 5};
matriz[7] = new Object[] {8, "Envigado", 11, 8, 3, 3, 2, 9, 9, 0};
matriz[8] = new Object[] {9, "Cucuta", 11, 7, 3, 2, 2, 9, 10, -1};
matriz[9] = new Object[] {10, "Aguilas", 11, 8, 3, 3, 2, 8, 11, -3};
matriz[10] = new Object[] {11, "Pasto", 10, 7, 2, 1, 4, 10, 6, 4};
matriz[11] = new Object[] {12, "Medellin", 10, 8, 3, 4, 1, 12, 11, 1};
matriz[12] = new Object[] {13, "Once Caldas", 10, 8, 2, 2, 8, 8, 7, 1};
matriz[13] = new Object[] {14, "Junior", 10, 8, 3, 4, 1, 3, 5, -2};
matriz[14] = new Object[] {15, "Bucamaranga", 9, 8, 2, 3, 3, 6, 6, 0};
matriz[15] = new Object[] {16, "Jaguares", 7, 8, 1, 3, 4, 5, 11, -6};
matriz[16] = new Object[] {17, "Huila", 6, 7, 1, 3, 3, 7, 14, -7};
matriz[17] = new Object[] {18, "Union Magdalena", 5, 7, 1, 4, 2, 4, 9, -5};
matriz[18] = new Object[] {19, "Equidad", 4, 7, 1, 5, 1, 7, 11, -4};
matriz[19] = new Object[] {20, "Santa Fe", 2, 8, 0, 6, 2, 1, 10, -9};
}
public String equipoConMenosPuntos() {
//Tomamos como referencia el primer registro para poder comparar
String equipo = (String) matriz[0][1];
int menosPuntos = (int) matriz[0][2];
//Buscamos quien tiene menos puntos
for (int i = 0; i < matriz.length; i++)
if ((int) matriz[i][2] < menosPuntos) {
menosPuntos = (int) matriz[i][2];
equipo = (String) matriz[i][1];
}
return equipo;
}
public String equipoMasGolesFavor() {
String equipo = (String) matriz[0][1];
int masGoles = (int) matriz[0][7];
for (int i = 0; i < matriz.length; i++)
if ((int) matriz[i][7] > masGoles) {
masGoles = (int) matriz[i][7];
equipo = (String) matriz[i][1];
}
return equipo;
}
public int golesTotales() {
int total = 0;
for (int i = 0; i < matriz.length; i++)
total += (int)matriz[i][7];
return total;
}
}