Reorgnizando la diferenciacion entre lo que suma y resta al total del

mes
This commit is contained in:
2019-11-14 20:31:28 +01:00
parent 0d7df06ad6
commit 21203e9524
7 changed files with 25 additions and 39 deletions

View File

@@ -9,20 +9,15 @@ public class Gestion{
private static float total;
private Month mes;
private Year anio;
//private boolean isPositivo;
private boolean isPositivo;
private String nombre;
public Gestion() {
this.gestiones=new Vector<Transaccion>();
this.suma = 0;
Gestion.total = 0;
}
public Gestion(String nombre) {
public Gestion(String nombre, boolean isPositivo) {
this.gestiones = new Vector<Transaccion>();
this.suma = 0;
Gestion.total = 0;
this.nombre = nombre;
this.isPositivo = isPositivo;
}
public String getNombre() {
@@ -32,7 +27,7 @@ public class Gestion{
public void aniadirGasto(Transaccion transaccion) {
this.gestiones.add(transaccion);
this.suma += transaccion.getDinero();
if(transaccion.isPositivo()) {
if(this.isPositivo) {
Gestion.total += transaccion.getDinero();
}else {
Gestion.total -= transaccion.getDinero();
@@ -54,14 +49,14 @@ public class Gestion{
public void alterarVisibilidad(int elemento) {
if(this.gestiones.get(elemento).alterarVisivilidad()) {
this.suma += this.gestiones.get(elemento).getDinero();
if(this.gestiones.get(elemento).isPositivo()) {
if(this.isPositivo) {
Gestion.total += this.gestiones.get(elemento).getDinero();
}else {
Gestion.total -= this.gestiones.get(elemento).getDinero();
}
}else {
this.suma -= this.gestiones.get(elemento).getDinero();
if(this.gestiones.get(elemento).isPositivo()) {
if(this.isPositivo) {
Gestion.total -= this.gestiones.get(elemento).getDinero();
}else {
Gestion.total += this.gestiones.get(elemento).getDinero();