Example #1
0
        static void Main(string[] args)
        {
            Account acc = new SBAccount(15000)
            {
                AccountNo = 11111, Name = "Dhilip"
            };

            Console.WriteLine("The Balance is " + acc.Balance);
        }
Example #2
0
        static void Main(string[] args)
        {
            Account acc = new SBAccount {
                AccountNo = 1111, AccountName = "Phaniraj"
            };                                                                        //Dependency inversion principle...

            acc.Credit(50000);
            acc.CalculateInterest();
            Console.WriteLine("The Current balance is " + acc.Balance);
        }
        //Abstract classes are incomplete, U cannot instantiate them..U should use Runtime Polymorphism to work those objects
        static void Main(string[] args)
        {
            Account acc = new SBAccount();

            acc.AccountNo    = 34244;
            acc.CustomerName = "Phaniraj";
            acc.CreditAmount(12000);
            acc.DebitAmount(500);
            acc.CalculateInterest();//Calculate interest based on SBAccc..
            //Console.WriteLine($"The Current balance is {acc.Balance.ToString("C")}");
            Console.WriteLine($"The Current Balance is {acc.Balance:C}");
            Console.WriteLine($"The Current Balance is {acc.Balance.ToString("C", new CultureInfo("EN-US"))}");
        }
        static void Main(string[] args)
        {
            //Use the object of the Abstract class but instantiate it to the Derived...
            Account acc = new SBAccount();

            acc.CreditAmount(5000);
            acc.CalculateInterest();
            Console.WriteLine("The Current balance is " + acc.Balance);

            acc = new RDAccount();
            acc.CreditAmount(5000);
            acc.CalculateInterest();
            Console.WriteLine("The Current balance is " + acc.Balance);
        }
        static void Main(string[] args)
        {
            Account acc = new SBAccount();//The class is incomplete, so U cannot instantiate it....

            acc.AccountNo = 12323;
            acc.Name      = "Phaniraj";
            acc.CreditAmount(5000);
            try
            {
                acc.Debit(6500);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            //acc.CalculateInterest();
            Console.WriteLine("The current balance is " + acc.Balance);
        }