CalculateInterest() 공개 추상적인 메소드

public abstract CalculateInterest ( int monthsCount ) : decimal
monthsCount int
리턴 decimal
예제 #1
0
        public double TotalInterestPaid()
        {
            double totalInterest = 0;

            for (int i = 0; i < accounts.Count; i++)
            {
                Account a = (Account)accounts[i];
                if (a.CalculateInterest() > 0)
                {
                    totalInterest += a.CalculateInterest();
                }
            }
            return(totalInterest);
        }
예제 #2
0
        public double TotalInterestEarned()
        {
            double totalEarn = 0;

            for (int i = 0; i < accounts.Count; i++)
            {
                Account a = (Account)accounts[i];
                if (a.CalculateInterest() < 0)
                {
                    totalEarn += a.CalculateInterest();
                }
            }
            return(Math.Abs(totalEarn));
        }
예제 #3
0
        static void TestInterest(Account account, int months = 12)
        {
            Console.WriteLine(account.Customer);

            for (int i = 1; i <= months; i++)
            {
                Console.WriteLine(account.CalculateInterest(i));
            }

            Console.WriteLine();
        }
예제 #4
0
        public double TotalInterestEarned()
        {
            double total = 0;

            for (int i = 0; i < accounts.Count; i++)
            {
                Account a    = (Account)accounts[i];
                double  intr = a.CalculateInterest();
                if (intr < 0)
                {
                    total += (-intr);
                }
            }
            return(total);
        }
예제 #5
0
        static void Main(string[] args)
        {
            Customer cus1 = new Customer("Tan Ah Kow", "2 Rich Street", "P123123", 20);
            Customer cus2 = new Customer("Kim May Mee", "89 Gold Road", "P334412", 60);

            Account a1 = new Account("S0000223", cus1, 2000);

            Console.WriteLine(a1.CalculateInterest());
            OverdraftAccount a2 = new OverdraftAccount("O1230124", cus1, 2000);

            Console.WriteLine(a2.CalculateInterest());
            CurrentAccount a3 = new CurrentAccount("C1230125", cus2, 2000);

            Console.WriteLine(a3.CalculateInterest());

            Console.WriteLine(a2.Show());
            a2.Withdraw(5000);
            //a2.TransferTo(445, a2); //OverdraftAccount does not have TransferTo method redefined, got error
            Console.WriteLine(a2.CalculateInterest());
            Console.WriteLine(a2.Show());
        }