Inheritance: Account, IAccount, IDepositable
示例#1
0
        static void Main()
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(new string('=', 42));

            // Create an instances of the new accounts
            DepositAccount  depositAcc  = new DepositAccount(CustomerType.Individual, "Gaius Julius Caesar", 3750, 5);
            LoanAccount     loanAccInd  = new LoanAccount(CustomerType.Individual, "King Leonidas", 5700, 4);
            LoanAccount     loanAccComp = new LoanAccount(CustomerType.Company, "Naglite Corp.", 67879, 3);
            MortgageAccount mortgageAcc = new MortgageAccount(CustomerType.Company, "Talasumi Ltd.", 3700, 4);

            // Testing of the Deposit Account, Custumer Type - Individual
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Customer Name: {0}\nCustomer Type: {1}", depositAcc.Customer, depositAcc.CustomerType);
            Console.WriteLine("Deposit balance is: {0}", depositAcc.Balance);
            depositAcc.DepositMoney(3000);
            Console.WriteLine("After depositing of 3000 the balance is: {0}", depositAcc.Balance);

            Console.WriteLine("Deposit balance is: {0}", depositAcc.Balance);
            depositAcc.WithdrawMoney(1000);
            Console.WriteLine("After withdrawing 1000 the balance is: {0}", depositAcc.Balance);

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(new string('=', 42));

            // Testing of the Loan Account, Custumer Type - Individual
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("Customer Name: {0}\nCustomer Type: {1}", loanAccInd.Customer, loanAccInd.CustomerType);
            Console.WriteLine("Deposit balance is: {0}", loanAccInd.Balance);
            loanAccInd.DepositMoney(1000);
            Console.WriteLine("After deposition of 1000 balance is: {0}", loanAccInd.Balance);

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(new string('=', 42));

            // Testing of the Loan Account, Custumer Type - Company
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Customer Name: {0}\nCustomer Type: {1}", loanAccComp.Customer, loanAccComp.CustomerType);
            Console.WriteLine("Deposit balance is: {0}", loanAccComp.Balance);
            loanAccComp.DepositMoney(7500);
            Console.WriteLine("After deposition of 7500 balance is: {0}", loanAccComp.Balance);

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(new string('=', 42));

            // Testing the Interest Amount
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Interest Ammount of the accounts for 18 months: \n{0}: {1} \n{2}: {3} \n{4}: {5}",
                              depositAcc.Customer, depositAcc.InterestAmount(18), loanAccInd.Customer, loanAccInd.InterestAmount(18),
                              loanAccComp.Customer, loanAccComp.InterestAmount(18), mortgageAcc.Customer, mortgageAcc.InterestAmount(18));

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(new string('=', 42));
        }
示例#2
0
        public static void Main()
        {
            ICustomer gosho = new IndividualCustomer("Georgi Georgiev");
            ICustomer myCompany = new CompanyCustomer("My Company Ltd.");

            IAccount mortAccInd = new MortgageAccount(gosho, 924m, 2.4m);
            IAccount mortgageAccComp = new MortgageAccount(myCompany, 888m, 7.4m);

            IAccount loanAccInd = new LoanAccount(gosho, 2048m, 4.5m);
            IAccount loanAccComp = new LoanAccount(myCompany, 512m, 6.0m);

            IAccount depositAccIndBig = new DepositAccount(gosho, 888, 6.6m);
            IAccount depositAccIndSmall = new DepositAccount(gosho, 1111m, 7.9m);
            IAccount depositAccComp = new DepositAccount(myCompany, 50326m, 4.9m);

            List<IAccount> accounts = new List<IAccount>()
            {
                mortAccInd,
                mortgageAccComp,
                loanAccInd,
                loanAccComp,
                depositAccIndBig,
                depositAccIndSmall,
                depositAccComp
            };

            foreach (var acc in accounts)
            {
                Console.WriteLine(
                    "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}",
                    acc.GetType().Name,
                    acc.CalculateRate(2),
                    acc.CalculateRate(3),
                    acc.CalculateRate(10),
                    acc.CalculateRate(13),
                    acc.Customer.GetType().Name);
            }
        }
示例#3
0
        public static void Main()
        {
            ICustomer pesho = new IndividualCustomer("Petar Petrov");
            ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd.");

            IAccount mortgageAccInd = new MortgageAccount(pesho, 1024m, 5.3m);
            IAccount mortgageAccComp = new MortgageAccount(agroCompany, 1024m, 5.3m);
            IAccount loanAccInd = new LoanAccount(pesho, 1024m, 5.3m);
            IAccount loanAccComp = new LoanAccount(agroCompany, 1024m, 5.3m);
            IAccount depositAccIndBig = new DepositAccount(pesho, 1024m, 5.3m);
            IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m);
            IAccount depositAccComp = new DepositAccount(agroCompany, 11024m, 4.3m);

            List<IAccount> accounts = new List<IAccount>()
            {
                mortgageAccInd,
                mortgageAccComp,
                loanAccInd,
                loanAccComp,
                depositAccIndBig,
                depositAccIndSmall,
                depositAccComp
            };

            foreach (var acc in accounts)
            {
                Console.WriteLine(
                    "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}",
                    acc.GetType().Name,
                    acc.CalculateRate(2),
                    acc.CalculateRate(3),
                    acc.CalculateRate(10),
                    acc.CalculateRate(13),
                    acc.Customer.GetType().Name);
            }
        }
示例#4
0
        public static void Main()
        {
            ICustomer pesho       = new IndividualCustomer("Petar Petrov");
            ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd.");

            IAccount mortgageAccInd     = new MortgageAccount(pesho, 1024m, 5.3m);
            IAccount mortgageAccComp    = new MortgageAccount(agroCompany, 1024m, 5.3m);
            IAccount loanAccInd         = new LoanAccount(pesho, 1024m, 5.3m);
            IAccount loanAccComp        = new LoanAccount(agroCompany, 1024m, 5.3m);
            IAccount depositAccIndBig   = new DepositAccount(pesho, 1024m, 5.3m);
            IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m);
            IAccount depositAccComp     = new DepositAccount(agroCompany, 11024m, 4.3m);

            List <IAccount> accounts = new List <IAccount>()
            {
                mortgageAccInd,
                mortgageAccComp,
                loanAccInd,
                loanAccComp,
                depositAccIndBig,
                depositAccIndSmall,
                depositAccComp
            };

            foreach (var acc in accounts)
            {
                Console.WriteLine(
                    "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}",
                    acc.GetType().Name,
                    acc.CalculateRate(2),
                    acc.CalculateRate(3),
                    acc.CalculateRate(10),
                    acc.CalculateRate(13),
                    acc.Customer.GetType().Name);
            }
        }