// History for current wallet in WalletList public void ShowHistory(Wallet wal) { Console.WriteLine(wal.name); foreach (Payment pay in wal.history) { if (pay is Transfer) { Transfer p = (Transfer)pay; if (p.from.name == wal.name) { Console.WriteLine(p.time + " " + pay.GetType().Name + " " + pay.sum + " To " + p.to.name); } else { Console.WriteLine(p.time + " " + pay.GetType().Name + " " + pay.sum + " From " + p.from.name); } } else if (pay is InputPayment) { InputPayment p = (InputPayment)pay; Console.WriteLine(p.time + " " + p.GetType().Name + " " + p.sum + " " + p.purpose); } else { OutputPayment p = (OutputPayment)pay; Console.WriteLine(p.time + " " + p.GetType().Name + " " + p.sum + " " + p.purpose); } } Console.WriteLine(); }
// Show data in percents of withdrawn funds public void FundsWithdrawn(Currency currency) { int count = 0; for (OutputPurpose i = OutputPurpose.Food; i <= OutputPurpose.Else; i++) { count++; } decimal[,] expenses = new decimal[count, 2]; decimal allExpenses = 0; foreach (Wallet wal in wallet) { if (wal.currency == currency) { int n = wal.history.Count; for (int i = 0; i < n; i++) { if (wal.history[i] is OutputPayment) { OutputPayment pay = (OutputPayment)wal.history[i]; expenses[(int)pay.purpose, 0] += wal.history[i].sum; allExpenses += wal.history[i].sum; } } } } string val = FindCurrency(currency); if (allExpenses == 0) { Console.WriteLine("There was not any payment in this currency"); } else { for (int i = 0; i < expenses.Length / 2; i++) { expenses[i, 1] = expenses[i, 0] / allExpenses; Console.WriteLine((OutputPurpose)i + " " + expenses[i, 0] + $" {val} " + expenses[i, 1] * 100 + "%"); } } Console.WriteLine(); }
// History for each wallet in WalletList, that has current currency public void ShowHistory(Currency type) { int numOfWallet = 0; foreach (Wallet wal in wallet) { if (wal.currency == type) { numOfWallet += 1; Console.WriteLine(wal.name); foreach (Payment pay in wal.history) { if (pay is Transfer) { Transfer p = (Transfer)pay; if (p.from.name == wal.name) { Console.WriteLine(p.time + " " + pay.GetType().Name + " " + pay.sum + " To " + p.to.name); } else { Console.WriteLine(p.time + " " + pay.GetType().Name + " " + pay.sum + " From " + p.from.name); } } else if (pay is InputPayment) { InputPayment p = (InputPayment)pay; Console.WriteLine(p.time + " " + p.GetType().Name + " " + p.sum + " " + p.purpose); } else { OutputPayment p = (OutputPayment)pay; Console.WriteLine(p.time + " " + p.GetType().Name + " " + p.sum + " " + p.purpose); } } Console.WriteLine(); } } if (numOfWallet == 0) { Console.WriteLine("You don't have any wallet of this currency"); } }