Reorgnizando la diferenciacion entre lo que suma y resta al total del
mes
This commit is contained in:
@@ -11,41 +11,41 @@ private ArrayList<Mes> meses;
|
||||
this.meses = new ArrayList<Mes>();
|
||||
}
|
||||
|
||||
public Gestion aniadirGestion(String nombre, int anio, Month mes) {
|
||||
public Gestion aniadirGestion(String nombre, int anio, Month mes, boolean isPositivo) {
|
||||
Gestion ret;
|
||||
try {
|
||||
for(Mes mesSelect:this.meses) {
|
||||
if(mesSelect.getMes().equals(mes) && mesSelect.getAnio() == anio){
|
||||
ret = new Gestion(nombre);
|
||||
ret = new Gestion(nombre, isPositivo);
|
||||
mesSelect.getGestiones().add(ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}catch (NullPointerException e) {
|
||||
ArrayList<Gestion> gestiones=new ArrayList<Gestion>();
|
||||
ret = new Gestion(nombre);
|
||||
ret = new Gestion(nombre, isPositivo);
|
||||
gestiones.add(ret);
|
||||
this.meses.add(new Mes(gestiones,anio,mes));
|
||||
return ret;
|
||||
}
|
||||
ArrayList<Gestion> gestiones=new ArrayList<Gestion>();
|
||||
ret = new Gestion(nombre);
|
||||
ret = new Gestion(nombre, isPositivo);
|
||||
gestiones.add(ret);
|
||||
this.meses.add(new Mes(gestiones,anio,mes));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void aniadirTransaccion(Transaccion transaccion, String nombre) {
|
||||
public void aniadirTransaccion(Transaccion transaccion, String nombre, boolean isPositivo) {
|
||||
for(Mes mes:this.meses) {
|
||||
if(transaccion.getDia().getMonth().equals(mes.getMes()) &&
|
||||
transaccion.getDia().getYear() == mes.getAnio()){
|
||||
mes.aniadirTransaccion(transaccion, nombre);
|
||||
mes.aniadirTransaccion(transaccion, nombre, isPositivo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.meses.add(new Mes(new ArrayList<Gestion>(),transaccion.getDia().getYear(),
|
||||
transaccion.getDia().getMonth()));
|
||||
this.meses.get(this.meses.size()-1).aniadirTransaccion(transaccion, nombre);
|
||||
this.meses.get(this.meses.size()-1).aniadirTransaccion(transaccion, nombre, isPositivo);
|
||||
}
|
||||
|
||||
public void elegirMes(int anio, Month mes) {
|
||||
@@ -75,14 +75,14 @@ class Mes{
|
||||
this.mes=mes;
|
||||
}
|
||||
|
||||
void aniadirTransaccion(Transaccion transaccion, String nombre) {
|
||||
void aniadirTransaccion(Transaccion transaccion, String nombre, boolean isPositivo) {
|
||||
for(Gestion gestion:this.gestiones) {
|
||||
if(gestion.getNombre().equals(nombre)) {
|
||||
gestion.aniadirGasto(transaccion);
|
||||
return;
|
||||
}
|
||||
}
|
||||
gestiones.add(new Gestion(nombre));
|
||||
gestiones.add(new Gestion(nombre, isPositivo));
|
||||
gestiones.get(this.gestiones.size()-1).aniadirGasto(transaccion);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user