Пример #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
        // 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");
            }
        }