Skip to content

Commit

Permalink
Merge pull request #30 from Java-Supremacists/correcionesFabri2
Browse files Browse the repository at this point in the history
eventosEnRango
  • Loading branch information
lima-limon-inc authored May 2, 2023
2 parents 751c15e + 88ddaeb commit 14d1fe6
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 144 deletions.
9 changes: 9 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ aa57a5f7aeb241b5b70e55124a2423bfabd5ffd9
# Lima Limon | Mon May 1 12:01:17 PM -03 2023
fc7327d81b85c7549aa48f38210f405ac51eaad2

# Lima Limon | Mon May 1 02:33:44 PM -03 2023
5f0c7a526c052b090aac53d16463113927d51760

# Lima Limon | Mon May 1 02:35:44 PM -03 2023
34e64b677ecdad43304179c49a035a8e8897fa51

# Lima Limon | Tue May 2 04:00:43 PM -03 2023
8edca3932b217853d7709558693d0334ecf3585d

172 changes: 30 additions & 142 deletions Diagrama/diagramaClases.dot
Original file line number Diff line number Diff line change
Expand Up @@ -59,153 +59,41 @@ digraph graph_name { graph [
<br align="left"/>}>]
actividad [comment = "green"]

frecuencia [color = "green"]//interfaz
frecuencia[label = <{
<b>Frecuencia</b>|
<br align="left"/>
dadoComienzoCaeDia<br align="left"/>
proximoEventoMasCercanoAFecha<br align="left"/>
<br align="left"/>}>]

repeticion [color = "green"]//interfaz
repeticion[label = <{
<b>Repeticion</b>|
<br align="left"/>
estaDentroDeRepeticiones<br align="left"/>
<br align="left"/>}>]

alarmas [color = "red"]//interfaz
alarmas[label = <{
<b>Alarmas</b>|
<br align="left"/>
actualizarAlarmas<br align="left"/>
agregarAlarmas<br align="left"/>
<br align="left"/>}>]

evento -> actividad [style = dotted]
tarea -> actividad [style = dotted]
calendario -> actividad [label = "Tiene"]

frecuencia -> evento [arrowhead = diamond]

repeticion -> frecuencia [arrowhead = diamond]


alarmas -> actividad [arrowhead = diamond]



}


/* digraph UML_Class_diagram { */
/* graph [ */
/* label="UML Class diagram demo" */
/* labelloc="t" */
/* fontname="Helvetica,Arial,sans-serif" */
/* ] */
/* node [ */
/* fontname="Helvetica,Arial,sans-serif" */
/* shape=record */
/* style=filled */
/* fillcolor=gray95 */
/* ] */
/* edge [fontname="Helvetica,Arial,sans-serif"] */
/* edge [arrowhead=vee style=dashed] */
/* Client -> Interface1 [label=dependency] */
/* Client -> Interface2 */

/* edge [dir=back arrowtail=empty style=""] */
/* Interface1 -> Class1 [xlabel=inheritance] */
/* Interface2 -> Class1 [dir=none] */
/* Interface2 [label="" xlabel="Simple\ninterface" shape=circle] */

/* Interface1[label = <{<b>«interface» I/O</b> | + property<br align="left"/>...<br align="left"/>|+ method<br align="left"/>...<br align="left"/>}>] */
/* Class1[label = <{<b>I/O class</b> | + property<br align="left"/>...<br align="left"/>|+ method<br align="left"/>...<br align="left"/>}>] */
/* edge [dir=back arrowtail=empty style=dashed] */
/* Class1 -> System_1 [label=implementation] */
/* System_1 [ */
/* shape=plain */
/* label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="4"> */
/* <tr> <td> <b>System</b> </td> </tr> */
/* <tr> <td> */
/* <table border="0" cellborder="0" cellspacing="0" > */
/* <tr> <td align="left" >+ property</td> </tr> */
/* <tr> <td port="ss1" align="left" >- Subsystem 1</td> </tr> */
/* <tr> <td port="ss2" align="left" >- Subsystem 2</td> </tr> */
/* <tr> <td port="ss3" align="left" >- Subsystem 3</td> </tr> */
/* <tr> <td align="left">...</td> </tr> */
/* </table> */
/* </td> </tr> */
/* <tr> <td align="left">+ method<br/>...<br align="left"/></td> </tr> */
/* </table>> */
/* ] */

/* edge [dir=back arrowtail=diamond] */
/* System_1:ss1 -> Subsystem_1 [xlabel="composition"] */

/* Subsystem_1 [ */
/* shape=plain */
/* label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="4"> */
/* <tr> <td> <b>Subsystem 1</b> </td> </tr> */
/* <tr> <td> */
/* <table border="0" cellborder="0" cellspacing="0" > */
/* <tr> <td align="left">+ property</td> </tr> */
/* <tr> <td align="left" port="r1">- resource</td> </tr> */
/* <tr> <td align="left">...</td> </tr> */
/* </table> */
/* </td> </tr> */
/* <tr> <td align="left"> */
/* + method<br/> */
/* ...<br align="left"/> */
/* </td> </tr> */
/* </table>> */
/* ] */
/* Subsystem_2 [ */
/* shape=plain */
/* label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="4"> */
/* <tr> <td> <b>Subsystem 2</b> </td> </tr> */
/* <tr> <td> */
/* <table align="left" border="0" cellborder="0" cellspacing="0" > */
/* <tr> <td align="left">+ property</td> </tr> */
/* <tr> <td align="left" port="r1">- resource</td> </tr> */
/* <tr> <td align="left">...</td> </tr> */
/* </table> */
/* </td> </tr> */
/* <tr> <td align="left"> */
/* + method<br/> */
/* ...<br align="left"/> */
/* </td> </tr> */
/* </table>> */
/* ] */
/* Subsystem_3 [ */
/* shape=plain */
/* label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="4"> */
/* <tr> <td> <b>Subsystem 3</b> </td> </tr> */
/* <tr> <td> */
/* <table border="0" cellborder="0" cellspacing="0" > */
/* <tr> <td align="left">+ property</td> </tr> */
/* <tr> <td align="left" port="r1">- resource</td> </tr> */
/* <tr> <td align="left">...</td> </tr> */
/* </table> */
/* </td> </tr> */
/* <tr> <td align="left"> */
/* + method<br/> */
/* ...<br align="left"/> */
/* </td> </tr> */
/* </table>> */
/* ] */
/* System_1:ss2 -> Subsystem_2; */
/* System_1:ss3 -> Subsystem_3; */

/* edge [xdir=back arrowtail=odiamond] */
/* Subsystem_1:r1 -> "Shared resource" [label=aggregation] */
/* Subsystem_2:r1 -> "Shared resource" */
/* Subsystem_3:r1 -> "Shared resource" */
/* "Shared resource" [ */
/* label = <{ */
/* <b>Shared resource</b> */
/* | */
/* + property<br align="left"/> */
/* ...<br align="left"/> */
/* | */
/* + method<br align="left"/> */
/* ...<br align="left"/> */
/* }> */
/* ] */
/* } */














/* public Evento(titulo, descripcion, esCompleto, Comienzo, Final, Alarmas) { */

/* this.titulo = titulo */
/* this.descripcion = descripcion */
/* this.esCompleto = esCompleto */
/* if this.esCompleto == True { */
/* this.Comienzo = (el dia que pasate a las 00) */
/* } */
/* this.Comienzo = Comienzo */

/* } */
Binary file modified Diagrama/diagramaClases.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Alumnos:
- Gerez Facundo Nahuel - 109429
- Orsi Tomas Fabrizio - 109735

![Diagrama UML](Diagrama/diagramaClases.png)

# Consigna
Lógica de negocio (etapa 1)

Expand Down
24 changes: 24 additions & 0 deletions src/main/java/Calendario.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import java.time.temporal.ChronoUnit; //Libreria para formatear dias en LocalDateTime
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -200,4 +201,27 @@ public void eliminarTarea(int ID) {
}
}

//Esta funcion va a devolver un array de ints que representan el id
//de todos los eventos que estan dentro del rango
//Esta funcion no es la mas eficiente del mundo, es un doble for
//se podria implementar una funcion llamada "esta en el rango" parecida a
//"cae el dia"
public ArrayList<Evento> eventosEnRango(LocalDateTime comienzo, LocalDateTime fin) {
var listaEventosEnRango = new ArrayList<Evento>();

long cantDias = comienzo.until(fin, ChronoUnit.DAYS);
for (Evento evento : this.listaEventos) {
LocalDateTime diaAChequear = comienzo;
//Chequeo todos los dias que hay entre comienzo y fin
for (int i = 0 ; i < cantDias ; i++ ) {
diaAChequear = diaAChequear.plusDays(i);
if (evento.caeElDia(diaAChequear) == true) {
listaEventosEnRango.add(evento);
break;
}
}
}
return listaEventosEnRango;
}

}
3 changes: 3 additions & 0 deletions src/main/java/FrecuenciaDiaria.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public boolean dadoComienzoCaeElDia(LocalDateTime fechaComienzo, LocalDateTime d

//Se fija cuantos dias hay hasta el dia pasado como argumento
long cantDiasHastaDiaPedido = fechaComienzo.until(diaEspecifico, ChronoUnit.DAYS);
if (cantDiasHastaDiaPedido < 0) {
return false; //Si es negativo, no puede caer
}

//True: El evento tiene una "aparicion" ese dia. False: no.
boolean eventoCaeElDiaPedidio = (cantDiasHastaDiaPedido % this.cadaCuantosDias == 0);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/RepeticionCantVeces.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public RepeticionCantVeces(int cantidadDeRepeticionesMaximas, int cadaCuantosDia
this.fechaFinRepeticion = fechaFinal;
}

public RepeticionCantVeces(int cantidadDeRepeticionesMaximas, LocalDateTime fechaComienzo, DayOfWeek[] diasDeLaSemana) {
public RepeticionCantVeces(int cantidadDeRepeticionesMaximas, DayOfWeek[] diasDeLaSemana, LocalDateTime fechaComienzo) {
//La idea de este for loop es que te diga en que dia DE LA SEMANA cae
//el ultimo dia
int diaDeLaSemana = -1; //Arranca en -1 porque lo primero que hace es
Expand Down
31 changes: 31 additions & 0 deletions src/test/java/CalendarioTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,35 @@ public void creacionesDeAlarmasCalendario() {
}
}

@Test
public void eventosDadoRangoDeFechas() {
Calendario calendarioDePrueba = new Calendario();

LocalDateTime comienzo = LocalDateTime.of(2023, 4, 13, 7, 45, 55);
LocalDateTime fin = LocalDateTime.of(2023, 4, 13, 10, 45, 55);
var indice = calendarioDePrueba.crearEvento(comienzo, fin);
RepeticionInfinita repeticionInfinita = new RepeticionInfinita();
FrecuenciaDiaria frecuenciaDiaria = new FrecuenciaDiaria(1, repeticionInfinita);
String descripcion = "Evento en rango";
calendarioDePrueba.modificarEventoFrecuencia(indice, frecuenciaDiaria);
calendarioDePrueba.modificarActividadDescripcion(indice, descripcion);

LocalDateTime comienzoFuera = LocalDateTime.of(2024, 4, 13, 7, 45, 55);
LocalDateTime finFuera = LocalDateTime.of(2024, 4, 13, 10, 45, 55);
var indiceFuera = calendarioDePrueba.crearEvento(comienzoFuera, finFuera);
RepeticionInfinita repeticionInfinitaFuera = new RepeticionInfinita();
FrecuenciaDiaria frecuenciaDiariaFuera = new FrecuenciaDiaria(1, repeticionInfinitaFuera);
String descripcionFuera = "Evento fuera de rango";
calendarioDePrueba.modificarEventoFrecuencia(indiceFuera, frecuenciaDiariaFuera);
calendarioDePrueba.modificarActividadDescripcion(indiceFuera, descripcionFuera);

var eventosEnRangoDeLaFecha = calendarioDePrueba.eventosEnRango(LocalDateTime.of(2023, 4, 11, 7, 45, 55), LocalDateTime.of(2023, 4, 15, 7, 45, 55));

assertEquals(descripcion, eventosEnRangoDeLaFecha.get(0).getDescripcion());
assertEquals(1, eventosEnRangoDeLaFecha.size()); //Solo tiene que tener un evento, el otro evento no deberia formar parte



}

}
2 changes: 1 addition & 1 deletion src/test/java/RepeticionCantVecesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void finDeLaRepeticionPorFechaArrayDaysOfWeek() {
LocalDateTime fechaComienzoRepeticion = LocalDateTime.of(2023, 4, 4, 7, 45, 55);
int maximaCantidadDeRepeticiones = 4;
DayOfWeek[] diasDeLaSemana = {DayOfWeek.TUESDAY, DayOfWeek.THURSDAY};
RepeticionCantVeces repeticionCantVecesDePrueba = new RepeticionCantVeces(maximaCantidadDeRepeticiones, fechaComienzoRepeticion, diasDeLaSemana);
RepeticionCantVeces repeticionCantVecesDePrueba = new RepeticionCantVeces(maximaCantidadDeRepeticiones, diasDeLaSemana, fechaComienzoRepeticion);

// Esta fecha es la que cae si haces la cuenta manualmente
// (Martes 4, Jueves 6, Martes 11 y Jueves 13)
Expand Down

0 comments on commit 14d1fe6

Please sign in to comment.