示例#1
0
        public static void Main()
        {
            // YOU CAN UNCOMMENT AND SEE THE TEST RESULTS. IT WAS INTERESTING :)
            var myAcc = new DepositAccount(new Individual("Ivan"), 300, 1M);

            Console.WriteLine(myAcc.Balance);

            Console.WriteLine(myAcc.CalculateInterestAmount(2));
            myAcc.DepositMoney(100, 2);
            Console.WriteLine(myAcc.Balance);

            myAcc.DrawMoney(50, 1);
            Console.WriteLine(myAcc.Balance);

            //var myLoanAcc = new LoanAccount(new Individual("Ivan"), -300, 1M);
            //Console.WriteLine(myLoanAcc.CalculateInterestAmount(4));
            //myLoanAcc.DepositMoney(200, 4);
            //Console.WriteLine(myLoanAcc.Balance);

            //var myLoanAcc = new LoanAccount(new Company("ET Ivan"), -300, 1M);
            //Console.WriteLine(myLoanAcc.CalculateInterestAmount(4));
            //myLoanAcc.DepositMoney(200, 4);
            //Console.WriteLine(myLoanAcc.Balance);

            //var myMortgageAcc = new MortgageAccount(new Company("ET Ivan"), -300, 1M);
            //Console.WriteLine(myMortgageAcc.Balance);
            //Console.WriteLine(myMortgageAcc.CalculateInterestAmount(-2));
            //myMortgageAcc.DepositMoney(30, 2);
            //Console.WriteLine(myMortgageAcc.Balance);
        }
        public static decimal CalcInterest(DepositAccount account, DateTime startDate)
        {
            if (account.CurrentAmount < 1000)
            {
                return 0m;
            }

            int months = (int)(DateTime.Now.Date - account.StartDate).TotalDays / 30;
            return months * account.InterestRate;
        }
示例#3
0
        public static decimal CalcInterest(DepositAccount account, DateTime startDate)
        {
            if (account.CurrentAmount < 1000)
            {
                return(0m);
            }

            int months = (int)(DateTime.Now.Date - account.StartDate).TotalDays / 30;

            return(months * account.InterestRate);
        }