Пример #1
0
 protected Account(Customer customer)
 {
     PrimaryAccountHolder = customer;
     AccountHolders.Add(PrimaryAccountHolder);
     AccountNumber = String.Format($"{++anb,0:D4}");
     Balance       = 0;
     AllAccounts.Add(this);
 }
Пример #2
0
        public void PayInterest()
        {
            decimal interest = Balance >= MinBalForInterest ? Balance * InterestRate : 0M;

            if (interest > 0)
            {
                Deposit(interest);
            }
            AllAccounts.LogTransaction(this, interest, "Interest");
        }
Пример #3
0
 public override void Withdraw(decimal amount)
 {
     if (Balance - amount >= 0)
     {
         base.Withdraw(amount);
     }
     else
     {
         AllAccounts.LogTransaction(this, amount, "Withdrawal", "DECLINED");
     }
 }
Пример #4
0
 public virtual void Withdraw(Decimal amount)
 {
     Balance -= amount;
     AllAccounts.LogTransaction(this, amount, "Withdrawal");
 }
Пример #5
0
        //part delegated

        public virtual void Deposit(Decimal amount)
        {
            Balance += amount;
            AllAccounts.LogTransaction(this, amount, "Deposit");
        }
Пример #6
0
        static void Main(string[] args)
        {
            Customer C = new Customer {
                Name = "Test1"
            };
            Account AC = new CurrentAccount(C);

            AC.Deposit(500M);
            AC.Withdraw(34.99M);

            C = new Customer {
                Name = "Test2"
            };
            CurrentAccount NAC;

            NAC = new CurrentAccount(C);
            NAC.OverdraftLimit = 200M;
            NAC.Withdraw(200M);
            NAC.Deposit(149.99M);

            C = new Customer {
                Name = "Test2"
            };
            AC = new SavingsAccount(C);
            AC.Deposit(149.99M);
            foreach (int i in Enumerable.Range(1, 3))
            {
                AC.Withdraw(50M);
            }

            PremiumSavingsAccount PSA;

            PSA = new PremiumSavingsAccount(new Customer()
            {
                Name = "G Mugabe",
            })
            {
                MinBalForInterest = 200M,
                InterestRate      = 0.04M
            };
            PSA.Deposit(1000M);
            PSA.PayInterest();
            PSA.Withdraw(900M);
            PSA.PayInterest();

            NAC = new CurrentAccount(
                new List <Customer>()
            {
                new Customer()
                {
                    Name = "Tom"
                },
                new Customer()
                {
                    Name = "Dick"
                },
                new Customer()
                {
                    Name = "Harry"
                }
            });
            NAC.Deposit(9999M);


            AllAccounts.ListAll();

            AllAccounts.ListOne(NAC);
            Console.ReadKey();
        }