Skip to content

Commit

Permalink
Merge pull request #11 from sebaignacioo/Asistencia
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaignacioo committed Oct 26, 2021
2 parents 319da6f + 63e5b0f commit fca6094
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import aplicacion.views.cli.UtilsCLI;

import java.io.IOException;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -47,7 +46,7 @@ public Alumno getAlumnoRequerido(int value){
if (value == 1 && (alumnoReq == null || alumno.getPromAsistencia() > alumnoReq.getPromAsistencia())) {
alumnoReq = alumno;
}
if (value == 0 && (alumnoReq == null || alumno.getPromAsistencia() > alumnoReq.getPromAsistencia()))
if (value == 0 && (alumnoReq == null || alumno.promRetiros() > alumnoReq.promRetiros()))
alumnoReq = alumno;
}
}
Expand All @@ -72,8 +71,7 @@ public Map<String, Alumno> getEntrePorcentajes(int percent1, int percent2, int v
if (value == 1)
alumnoReq = (int) Math.round((alumno.getPromAsistencia() * 100.0));
if (value == 0)
// Todo: Funcion para generar dato de cantidad de retiros.
alumnoReq = (int) Math.round((alumno.getPromAsistencia() * 100.0));
alumnoReq = (int) Math.round((alumno.promRetiros() * 100.0));
if (alumnoReq >= percent1 && alumnoReq <= percent2)
alumnos.put(alumno.getRut(), alumno);
}
Expand Down Expand Up @@ -105,12 +103,10 @@ public void alumnosEntrePorcentajesAsistencia() throws IOException {

public void alumnoConMasRetiros() throws IOException {
Alumno alumno;
DecimalFormat df = new DecimalFormat("##.##");

System.out.println("Alumno con mas retiros: ");
alumno = getAlumnoRequerido(0);
// Todo: Funcion para generar dato de cantidad de retiros.
System.out.println(alumno.getNombreCompleto() + " con " + df.format(alumno.getPromAsistencia()) + "% de retiros");
System.out.println(alumno.toString("del alumno con mas retiros"));
}

public void alumnoEntrePorcentajesRetiros() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public HashMap<IDAsistencia, RegistroAsistencia> getRegistroAsistencia(String ru
parts = csv.split(",");
if (parts[0].equals(rutAlumno)) {
id = new IDAsistencia(parts[0], Date.valueOf(parts[1]));
System.out.println(csv);
System.out.println(String.format("presente %s - justificado %s - retiro %s", Boolean.parseBoolean(parts[2]),
Boolean.parseBoolean(parts[3]), Boolean.parseBoolean(parts[4])));
//System.out.println(csv);
//System.out.println(String.format("presente %s - justificado %s - retiro %s", Boolean.parseBoolean(parts[2]),
//Boolean.parseBoolean(parts[3]), Boolean.parseBoolean(parts[4])));
registro.put(id, regitroAsistenciaFromCSV(csv));
}
}
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/aplicacion/models/Alumno.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ private void actualizarPromedio() {
this.promAsistencia = suma / dias;
}

public float promRetiros(){
float diasRetirado = 0.0f;
float diasTotales = 0.0f;
for (Map.Entry<IDAsistencia, RegistroAsistencia> registro: this.asistencia.entrySet()) {
if (registro.getValue().retirado())
diasRetirado++;
diasTotales++;
}
return diasRetirado / diasTotales;
}

/**
* Obtener apoderado asociado al alumno
*
Expand Down Expand Up @@ -123,14 +134,16 @@ public String toString() {
return super.toString("Alumno") +
" -> Curso : " + Curso.cursoToString(nivel, paralelo) + "\n" +
" -> Apoderado : " + apoderado.getRut() + " - " + apoderado.getNombreCompleto() + "\n" +
" -> Prom. Asistencia : " + String.format("%.1f", getPromAsistencia() * 100) + " %\n";
" -> Prom. Asistencia : " + String.format("%.1f", getPromAsistencia() * 100) + " %\n" +
" -> Prom. Retiros : " + String.format("%.1f", promRetiros() * 100) + " %\n";
}

@Override
public String toString(String titulo) {
return super.toString(titulo) +
" -> Curso : " + Curso.cursoToString(nivel, paralelo) + "\n" +
" -> Apoderado : " + apoderado.getRut() + " - " + apoderado.getNombreCompleto() + "\n" +
" -> Prom. Asistencia : " + String.format("%.1f", getPromAsistencia() * 100) + " %\n";
" -> Prom. Asistencia : " + String.format("%.1f", getPromAsistencia() * 100) + " %\n" +
" -> Prom. Retiros : " + String.format("%.1f", promRetiros() * 100) + " %\n";
}
}
32 changes: 21 additions & 11 deletions src/main/java/aplicacion/views/cli/AsistenciaViewCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,27 @@ public class AsistenciaViewCli {
public static void mostrarTablaAlumnosAsistencia(Map<String, Alumno> alumnos, String curso) {
int i = 0;
Object[][] data = new Object[alumnos.size()][UtilsCLI.headers.get("asistencia").length];
for (Alumno alumno : alumnos.values()) {
data[i][0] = alumno.getRut();
data[i][1] = alumno.getApPaterno();
data[i][2] = alumno.getApMaterno();
data[i][3] = alumno.getNombres();
data[i][4] = alumno.getApoderado().getNombreCompleto();
data[i][5] = alumno.getApoderado().getTelefono();
data[i][6] = alumno.getPromAsistencia();
i++;
if (alumnos.isEmpty()){
System.out.println("No hay alumnos que cumplan los parametros, vuelva a intentar con otros");
}else {
for (Alumno alumno : alumnos.values()) {
data[i][0] = alumno.getRut();
data[i][1] = alumno.getApPaterno();
data[i][2] = alumno.getApMaterno();
data[i][3] = alumno.getNombres();
data[i][4] = alumno.getApoderado().getNombreCompleto();
data[i][5] = alumno.getApoderado().getTelefono();
if (curso.equals("porcentaje dado ASISTENCIA"))
data[i][6] = String.format("%.2f", alumno.getPromAsistencia() * 100);
else
data[i][6] = String.format("%.2f", alumno.promRetiros() * 100);
i++;
}
if (curso.equals("porcentaje dado ASISTENCIA"))
UtilsCLI.imprimirTabla(data, UtilsCLI.headers.get("asistencia"), "Asistencia");
else
UtilsCLI.imprimirTabla(data, UtilsCLI.headers.get("retiros"), "Retiros");

}
UtilsCLI.imprimirTabla(data, UtilsCLI.headers.get("asistencia"), "Asistencia de alumnos del " + curso);
}

}
10 changes: 10 additions & 0 deletions src/main/java/aplicacion/views/cli/UtilsCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public class UtilsCLI {
"Teléfono apoderado",
"% Asistencia"
});

put("retiros", new String[]{
"RUT",
"Ap. Paterno",
"Ap. Materno",
"Nombres",
"Nombre completo apoderado",
"Teléfono apoderado",
"% Retiros"
});
}};

/**
Expand Down

0 comments on commit fca6094

Please sign in to comment.