示例#1
0
 // 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();
 }
示例#2
0
        // Show data in percents of recived funds
        public void FundsRecived(Currency currency)
        {
            int count = 0;

            for (InputPurpose i = InputPurpose.Salary; i <= InputPurpose.Else; i++)
            {
                count++;
            }
            decimal[,] funds = new decimal[count, 2];
            decimal allFunds = 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 InputPayment)
                        {
                            InputPayment pay = (InputPayment)wal.history[i];
                            funds[(int)pay.purpose, 0] += wal.history[i].sum;
                            allFunds += wal.history[i].sum;
                        }
                    }
                }
            }
            string val = FindCurrency(currency);

            if (allFunds == 0)
            {
                Console.WriteLine("There was not any payment in this currency");
            }
            else
            {
                for (int i = 0; i < funds.Length / 2; i++)
                {
                    funds[i, 1] = Math.Round(funds[i, 0] / allFunds, 5);
                    Console.WriteLine((InputPurpose)i + "    " + funds[i, 0] + $" {val} " + funds[i, 1] * 100 + "%");
                }
            }
            Console.WriteLine();
        }
示例#3
0
        // 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");
            }
        }