Untitled
unknown
dot
2 years ago
2.5 kB
13
Indexable
using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; namespace Agenda_personale { internal class Bilancio3 { private List<Movimento> singoleSpese = new List<Movimento>(); // le liste devono stare private private List<Movimento> ReportDelMese = new List<Movimento>(); private List<Movimento> ReportDelGiorno = new List<Movimento>(); public double SaldoResiduo() { double totale = 0; for (int i = 0; i < singoleSpese.Count; i++) // singoleSpese è legato a RegistraSpese che aggiunge spese (e date) individuali { Movimento spesa = singoleSpese[i]; totale = totale + spesa.Totale; // .Totale è una proprietà } Console.WriteLine(totale); return totale; } public void tutteLeSpese() { foreach (Movimento s in singoleSpese) // ci dà lui l'oggetto da scorrere Console.WriteLine(s.Totale + " " + s.Data); } public void RegistraMovimento(Movimento s) { this.singoleSpese.Add(s); for (int i = 0; i < singoleSpese.Count; i++) { int giorno = singoleSpese[i].Data.Day; int mese = singoleSpese[i].Data.Month; int anno = singoleSpese[i].Data.Year; DateTime oggi = DateTime.Now; if (giorno == oggi.Day) { if (mese == oggi.Month) { if (anno == oggi.Year) { this.ReportDelGiorno.Add(s); } } return; } else if (mese == oggi.Month) { if (anno == oggi.Year) { this.ReportDelMese.Add(s); } } } return; } public void ReportGiornaliero() { Console.Write(ReportDelGiorno.Select(m => m.Totale).Sum()); } public void ReportMensile() { Console.Write(ReportDelMese.Select(m => m.Totale).Sum()); }
Editor is loading...