コード例 #1
0
        public static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Pesho"),
                new IndividualCustomer("Gosho"),
                new CompanyCustomer("Soft Uni LTD"),
                new CompanyCustomer("Manchester United FC"),
            };

            var depositAcc  = new DepositAccount(clients[0], 8955.33m, 0.005);
            var loanAcc     = new LoanAccount(clients[1], 500m, 0.002);
            var mortgageAcc = new MortgageAccount(clients[2], 5m, 0.009);
            var depositAcc2 = new DepositAccount(clients[3], 159, 0.08);

            depositAcc.Withdraw(6000m);
            depositAcc2.Withdraw(54.22m);
            mortgageAcc.Deposit(15m);
            loanAcc.Deposit(5559.66m);

            try
            {
                depositAcc.Withdraw(500000000m);
            }
            catch (ArgumentException ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            Console.WriteLine(depositAcc2);
            Console.WriteLine(mortgageAcc);

            Console.WriteLine(loanAcc + $" Interest rate: {loanAcc.CalculateIntereset(12):C}");
        }
コード例 #2
0
        public static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Pesho"),
                new IndividualCustomer("Gosho"),
                new CompanyCustomer("Soft Uni LTD"),
                new CompanyCustomer("Manchester United FC"),
            };

            var depositAcc = new DepositAccount(clients[0], 8955.33m, 0.005);
            var loanAcc = new LoanAccount(clients[1], 500m, 0.002);
            var mortgageAcc = new MortgageAccount(clients[2], 5m, 0.009);
            var depositAcc2 = new DepositAccount(clients[3], 159, 0.08);

            depositAcc.Withdraw(6000m);
            depositAcc2.Withdraw(54.22m);
            mortgageAcc.Deposit(15m);
            loanAcc.Deposit(5559.66m);

            try
            {
                depositAcc.Withdraw(500000000m);
            }
            catch (ArgumentException ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            Console.WriteLine(depositAcc2);
            Console.WriteLine(mortgageAcc);

            Console.WriteLine(loanAcc + $" Interest rate: {loanAcc.CalculateIntereset(12):C}");
        }
コード例 #3
0
        static void Main()
        {
            Customer firstCustomer  = new Customer("Dimitar", "Stoyanov", 14, CustomersType.Individual);
            Customer secondCustomer = new Customer("Dominik", "Stoyanov", 19, CustomersType.Individual);
            Customer thirdCustomer  = new Customer("Ivan", "Rusinov", 10, CustomersType.Company);

            DepositAccount  firstAcc  = new DepositAccount(firstCustomer, 700, 8);
            DepositAccount  firstAcc2 = new DepositAccount(firstCustomer, 1600, 8);
            LoanAccount     secondAcc = new LoanAccount(secondCustomer, 6000, 10);
            MortgageAccount thirdAcc  = new MortgageAccount(thirdCustomer, 3000, 9);
            MortgageAccount thirdAcc2 = new MortgageAccount(thirdCustomer, 3000, 9);

            Console.WriteLine(firstAcc.CalculateInterest(0.5m, 5));
            Console.WriteLine(firstAcc2.CalculateInterest(0.5m, 10));
            Console.WriteLine(secondAcc.CalculateInterest(0.5m, 3));
            Console.WriteLine(secondAcc.CalculateInterest(0.5m, 4));
            Console.WriteLine(thirdAcc.CalculateInterest(1m, 13));
            Console.WriteLine(thirdAcc.CalculateInterest(1m, 12));

            firstAcc.Deposit(400);
            Console.WriteLine(firstAcc.CalculateInterest(0.5m, 10));
            Console.WriteLine(firstAcc.Withdraw(1050));
        }
コード例 #4
0
ファイル: Test.cs プロジェクト: KStoilkov/SoftUni
        static void Main()
        {
            Customer vanko = new IndividualCustomer("Vanko");
            Customer kroki = new CompanyCustomer("Kroki");
            Customer valq  = new IndividualCustomer("Valq");

            Account vankoAccount = new DepositAccount(vanko, 1450.59, 9);
            Account krokiAccount = new LoanAccount(kroki, 55623.89, 7);
            Account valqAccount  = new MortgageAccount(valq, 901.12, 6);

            IList <Account> accounts = new List <Account>
            {
                vankoAccount, valqAccount, krokiAccount
            };

            Bank bank = new Bank("KukuBanka", accounts);

            Console.WriteLine(bank);

            foreach (var account in accounts)
            {
                Console.WriteLine(account.CalculateInterest(12));
            }
        }