Corregir bugs y aniadir la opcion de eliminar transacciones
This commit is contained in:
@@ -6,7 +6,7 @@ import java.util.Vector;
|
||||
public class Gestion{
|
||||
private Vector<Transaccion> gestiones;
|
||||
private float suma;
|
||||
private static float total = 0;
|
||||
private float total;
|
||||
private Month mes;
|
||||
private Year anio;
|
||||
private boolean isPositivo;
|
||||
@@ -15,6 +15,7 @@ public class Gestion{
|
||||
public Gestion(String nombre, boolean isPositivo) {
|
||||
this.gestiones = new Vector<Transaccion>();
|
||||
this.suma = 0;
|
||||
this.total = 0;
|
||||
this.nombre = nombre;
|
||||
this.isPositivo = isPositivo;
|
||||
}
|
||||
@@ -27,9 +28,9 @@ public class Gestion{
|
||||
this.gestiones.add(transaccion);
|
||||
this.suma += transaccion.getDinero();
|
||||
if(this.isPositivo) {
|
||||
Gestion.total += transaccion.getDinero();
|
||||
this.total += transaccion.getDinero();
|
||||
}else {
|
||||
Gestion.total -= transaccion.getDinero();
|
||||
this.total -= transaccion.getDinero();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,28 +38,37 @@ public class Gestion{
|
||||
return this.suma;
|
||||
}
|
||||
|
||||
public static float getTotal() {
|
||||
return Gestion.total;
|
||||
public float getTotal() {
|
||||
return this.total;
|
||||
}
|
||||
|
||||
public Vector<Transaccion> getElementos(){
|
||||
return this.gestiones;
|
||||
}
|
||||
|
||||
public void eliminarTransaccion(String transaccion) {
|
||||
for(Transaccion elemento:this.gestiones) {
|
||||
if(elemento.toString().equals(transaccion)) {
|
||||
this.gestiones.remove(elemento);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void alterarVisibilidad(int elemento) {
|
||||
if(this.gestiones.get(elemento).alterarVisivilidad()) {
|
||||
this.suma += this.gestiones.get(elemento).getDinero();
|
||||
if(this.isPositivo) {
|
||||
Gestion.total += this.gestiones.get(elemento).getDinero();
|
||||
this.total += this.gestiones.get(elemento).getDinero();
|
||||
}else {
|
||||
Gestion.total -= this.gestiones.get(elemento).getDinero();
|
||||
this.total -= this.gestiones.get(elemento).getDinero();
|
||||
}
|
||||
}else {
|
||||
this.suma -= this.gestiones.get(elemento).getDinero();
|
||||
if(this.isPositivo) {
|
||||
Gestion.total -= this.gestiones.get(elemento).getDinero();
|
||||
this.total -= this.gestiones.get(elemento).getDinero();
|
||||
}else {
|
||||
Gestion.total += this.gestiones.get(elemento).getDinero();
|
||||
this.total += this.gestiones.get(elemento).getDinero();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user