From 0ade46bde2abd0ef95880e3b19367d4f345755e6 Mon Sep 17 00:00:00 2001 From: Guillermo Date: Thu, 14 Nov 2019 09:32:41 +0100 Subject: [PATCH] Comit saltando clase --- src/Logica/Meses.java | 53 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/src/Logica/Meses.java b/src/Logica/Meses.java index ebdf0c9..e9883fb 100644 --- a/src/Logica/Meses.java +++ b/src/Logica/Meses.java @@ -5,14 +5,38 @@ import java.util.ArrayList; public class Meses { private ArrayList meses; + private int mesActual=0; + public Meses() { this.meses=new ArrayList(); } - public void aniadirTransaccion() { - + public void aniadirTransaccion(Transaccion transaccion, String nombre) { + for(Mes mes:this.meses) { + if(transaccion.getDia().getMonth().equals(mes.getMes()) && + transaccion.getDia().getYear()==mes.getAnio()){ + mes.aniadirTransaccion(transaccion, nombre); + return; + } + } + this.meses.add(new Mes(new ArrayList())); + this.meses.get(this.meses.size()-1).aniadirTransaccion(transaccion, nombre); } + public void elegirMes(int anio, Month mes) { + for(int i=0;i getGestionesActuales(){ + return this.meses.get(this.mesActual).getGestiones(); + } + + + } @@ -24,4 +48,29 @@ class Mes{ Mes(ArrayList gestiones){ this.gestiones=gestiones; } + + void aniadirTransaccion(Transaccion transaccion, String nombre) { + for(Gestion gestion:this.gestiones) { + if(gestion.getNombre().equals(nombre)) { + gestion.aniadirGasto(transaccion); + return; + } + } + gestiones.add(new Gestion(nombre)); + gestiones.get(this.gestiones.size()-1).aniadirGasto(transaccion); + return; + } + + Month getMes() { + return this.mes; + } + + int getAnio() { + return this.anio; + } + + ArrayList getGestiones(){ + return this.gestiones; + } + }