73 lines
1.7 KiB
Java
73 lines
1.7 KiB
Java
package Logica;
|
|
import java.time.Month;
|
|
import java.time.Year;
|
|
import java.util.Vector;
|
|
|
|
public class Gestion{
|
|
private Vector<Transaccion> gestiones;
|
|
private float suma;
|
|
private static float total;
|
|
private Month mes;
|
|
private Year anio;
|
|
//private boolean isPositivo;
|
|
private String nombre;
|
|
|
|
public Gestion() {
|
|
this.gestiones=new Vector<Transaccion>();
|
|
this.suma = 0;
|
|
Gestion.total = 0;
|
|
}
|
|
|
|
public Gestion(String nombre) {
|
|
this.gestiones = new Vector<Transaccion>();
|
|
this.suma = 0;
|
|
Gestion.total = 0;
|
|
this.nombre = nombre;
|
|
}
|
|
|
|
public String getNombre() {
|
|
return this.nombre;
|
|
}
|
|
|
|
public void aniadirGasto(Transaccion transaccion) {
|
|
this.gestiones.add(transaccion);
|
|
this.suma += transaccion.getDinero();
|
|
if(transaccion.isPositivo()) {
|
|
Gestion.total += transaccion.getDinero();
|
|
}else {
|
|
Gestion.total -= transaccion.getDinero();
|
|
}
|
|
}
|
|
|
|
public float getSuma() {
|
|
return this.suma;
|
|
}
|
|
|
|
public static float getTotal() {
|
|
return Gestion.total;
|
|
}
|
|
|
|
public Vector<Transaccion> getElementos(){
|
|
return this.gestiones;
|
|
}
|
|
|
|
public void alterarVisibilidad(int elemento) {
|
|
if(this.gestiones.get(elemento).alterarVisivilidad()) {
|
|
this.suma += this.gestiones.get(elemento).getDinero();
|
|
if(this.gestiones.get(elemento).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()) {
|
|
Gestion.total -= this.gestiones.get(elemento).getDinero();
|
|
}else {
|
|
Gestion.total += this.gestiones.get(elemento).getDinero();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|